Collections Methods Flashcards
Sorting (Ascending Sorting , Low -> High)
Collections.sort(list);
Reverse sorting (Descending Sorting , High -> Low)
Method 1 - Collections. sort (list,Collections.reverseOrder());
Method 2 - Collection.reverse(list);
Randomly Order a List’s Elements
Collections.shuffle();
Set every element of the list to a specified Object
Collections.fill(list,”Element”);
Copy the content of one list to another
Collections.copy(CopyList,OriginalList);
Find the Smallest Element in the list
Collections.min(list);
Find the Largest Element in the list
Collections.max(list);
Binary search of an element
Collections.binarySearch(List,key);
Frequency of an element in a List
Collections.frequency (List,”Element”);
Determine whether two list have any element common or not - Returns Boolean
Collections.disjoint(list1,list2);