Performing Binary Search on Java float Array Example
import java.util.Arrays;
public class Main {
public static void main(String[] args) {
float floatArray[] = { 1.2f, 2.1f, 4.7f, 5.3f };
Arrays.sort(floatArray);
float searchValue = 4.7f;
System.out.println(Arrays.binarySearch(floatArray, searchValue));
searchValue = 3.3f;
System.out.println(Arrays.binarySearch(floatArray, searchValue));
}
}
Related examples in the same category