Collection class Methods in Java Part -III

java.util.Collections

This class consists exclusively of static methods that operate on or return collections. This class is a member of the Java Collections Framework.


Some Methods of Collections class.


Collections.shuffle(List): This method randomly permutes the specified list using a default source of randomness.


Collections.shuffle(List, Random): This method randomly permutes the specified list using the specified source of randomness.


Collections.singleton(List):  This method returns an immutable set containing only the specified object.


Collections.singletonList(List): This method returns an immutable list containing only the specified object.


Collections.singletonMap(E1, E2): This method returns an immutable map, mapping only the specified key to the specified value.


Collections.sort(List): This method sorts the specified list into ascending order, according to the natural ordering of its elements.


Collections.sort(List, Comparator): This method sorts the specified list according to the order induced by the specified comparator.


Collections.swap(List, int, int):  This method swaps the elements at the specified positions in the specified list.


Collections.synchronizedCollection(Collection): This method returns a synchronized (thread-safe) collection backed by the specified collection.


Collections.synchronizedList(List): This method returns a synchronized (thread-safe) list backed by the specified list.


Collections.synchronizedMap(Map): This method returns a synchronized (thread-safe) map backed by the specified map.


Collections.synchronizedNavigableMap(NavigableMap): This method returns a synchronized (thread-safe) navigable map backed by the specified navigable map.


Collections.synchronizedNavigableSet(NavigableSet): This method returns a synchronized (thread-safe) navigable set backed by the specified navigable set.


Collections.synchronizedSet(Set): This method returns a synchronized (thread-safe) set backed by the specified set.


Collections.synchronizedSortedMap(SortedMap): This method returns a synchronized (thread-safe) sorted map backed by the specified sorted map.


Collections.synchronizedSortedSet(SortedSet): This method returns a synchronized (thread-safe) sorted set backed by the specified sorted set.


Collections.unmodifiableCollection(Collection): This method returns an unmodifiable view of the specified collection.


Collections.unmodifiableList(List): This method returns an unmodifiable view of the specified list.


Collections.unmodifiableMap(Map): This method returns an unmodifiable view of the specified map.


Collections.unmodifiableNavigableMap(NavigableMap): This method returns an unmodifiable view of the specified navigable map.


Collections.unmodifiableNavigableSet(NavigableSet): This method returns an unmodifiable view of the specified navigable set.


Collections.unmodifiableSet(Set): This method returns an unmodifiable view of the specified set.


Collections.unmodifiableSortedMap(SortedMap): This method returns an unmodifiable view of the specified sorted map.


Collections.unmodifiableSortedSet(SortedSet): This method returns an unmodifiable view of the specified sorted set.


Some more Methods of Collections class Part -I


Some more Methods of Collections class Part -II


No comments:

Post a Comment