Class relations:
+ java.lang.Object
+ - java.util.Collections
This class is a member of Java Collections Framework.
This class is a utility class that contains exclusively of static methods that operate on or return Java collections like sorting, searching, and modifying elements within a collection.
Collections methods
Method
Description
Ref
static <T> boolean addAll(Collection<? super T>c, T... elements)
Add all specified elements to the specified collection
static <T extends Comparable<? super T>> void sort(List<T> list)
Sorts the specified list into ascending order, according to the natural ordering of the elements
static <T> void sort(List<T> list, Comparator<? super T> c
Sorts the specified list according to the order induced by the specified comparator
static <T extends Comparable<? super T> void sort(List<T> list)
Sorts the specified list into ascending order, according to the natural ordering of its elements
static <T> Queue<T> asLifoQueue(Deque<T> deque
Returns a view of Deque as Last-in-first-out (Lifo) queue
addAll()
The add all method adds all of the specified elements or collection to a target collection. It is useful when combining two collections or copy elements from one collection to another.
[1, 2, 3, 4, 5]
sort()
This method works with lists of any type T that extends Comparable <? super T>. Which is the element of the list must implement the comparable interface to themselves or any of their super class. (More about generics in Generics)
The sort method can also take a Comparator as an argument. This allows you to define a custom ordering for elements in a list. The method signature for this variation is: