I am trying to find the index of a double in a double array, it works for strings and integer arrays but not double.
double[] a = {1.1,2.2,3.3};
System.out.println(Arrays.asList(a).indexOf(1.1));
It keeps returning -1.
It won't work with int
array either. Arrays.asList(a)
returns a List<double[]>
whose single element is the input array, so it doesn't contain the element 1.1
.
Try
Double[] a = {1.1,2.2,3.3};
System.out.println(Arrays.asList(a).indexOf(1.1));
instead.