November 2006
Intermediate to advanced
224 pages
3h 29m
English
// sorting an array int[] myInts = {1,5,7,8,2,3}; Arrays.sort(myInts); // sorting a List List myList = new ArrayList(); myList.put(obj1); myList.put(obj2); Collections.sort(myList); |
The Arrays class is a class in the java.util package that contains a bunch of static methods for manipulating arrays. The useful method here is the sort() method. The sort() method takes an array of objects or primitives along with optional from and to indexes. The from index, if passed, would specify the index of the first element to be sorted, and the to index would specify the index of the last element to be sorted. Primitives are sorted in ascending order. When using this method to sort objects, all the objects must implement the Comparable ...
Read now
Unlock full access