Sorting an Integer array
As you say, this is wrong. This

Integer[] random = {6, -4, 12, 0, -10};
List&lt;Integer&gt; list = new ArrayList&lt;Integer&gt;(Arrays.asList(random));
Collections.sort(list);
Integer[] array = list.toArray(new Integer[list.size()]);


could be replaced by

Integer[] random = {6, -4, 12, 0, -10};
List&lt;Integer&gt; list = Arrays.asList(random);
Collections.sort(random);


where Arrays.asList just wraps the array without making a copy. Even better would be

Integer[] random = {6, -4, 12, 0, -10};
Arrays.sort(random);




Also note that sorting something just in order to be able to use binary search once makes no sense.

Also note that

Integer[] random = {6, -4, 12, 0, -10};


uses objects wrapping the int, while

int[] random = {6, -4, 12, 0, -10};


would be much more efficient.