I'm sorry for the stupid question, I have been searching about how to use binarysearch with my ArrayList like this :
List<Integer> arrList = new ArrayList<Integer>();
arrList.add(3);
arrList.add(5);
arrList.add(7);
arrList.add(2);
The problem is when I use :
Collections.sort(arrList);
Collections.reverse(arrList);
int indeks = Collections.binarySearch(arrList, 7);
the value of indeks is always -5, I thought it should be 2 because after reversing myArrList the output looks like this :
[7, 5, 3, 2]
So what should I do here in order to get the right indeks of 7...? Thanks in advance
binarySearchsay?