I'm trying to search value in an int array using Arrays.binarySearch(), and i know that if value would find in array this method returns value's index number and if array doesn't include value method returns a negative number.
Here is my array:
int[] searchInArray=new int[6];
searchInArray = new int[]{2,3,4,22,1,2};
And here is my code:
int result1=Arrays.binarySearch(searchInArray,55);
int result2=Arrays.binarySearch(searchInArray, 22);
When I run this code I get return1=-7 and return2=-7.
Then I try to find 1 instead of 22 then result2 being "-1".
Where am I making mistake?