You need to ensure that the array has been sorted before attempting to use a binary search. The following code should work as you expect:
int[] searchInArray = new int[6];
searchInArray = new int[] { 2, 3, 4, 22, 1, 2 };
Arrays.sort(searchInArray);
final int result1 = Arrays.binarySearch(searchInArray, 55);
final int result2 = Arrays.binarySearch(searchInArray, 22);
System.out.println("result1 " + result1);
System.out.println("result2 " + result2);
Also you shouldn't be expecting the return -1. Arrays.binarySearch
returns a negative number to indicate where the value should be inserted. From the javadoc:
index of the search key, if it is contained in the array; otherwise, (-(insertion point) - 1). The insertion point is defined as the point at which the key would be inserted into the array: the index of the first element greater than the key, or a.length if all elements in the array are less than the specified key. Note that this guarantees that the return value will be >= 0 if and only if the key is found.