<<< Arrays.sort | Index | Example of search within unsorted array >>> |
Code that uses the sort and binarySearch methods
String[] productCodes = {"mcbl", "jsps", "java"}; Arrays.sort(productCodes); int index = Arrays.binarySearch(productCodes, "mcbl"); // sets index to 2
<<< Arrays.sort | Index | Example of search within unsorted array >>> |