Collections class Methods in Java Part -II

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.emptyNavigableMap()This method returns an empty navigable map.


Collections.emptyNavigableSet()This method returns an empty navigable set.


Collections.emptySet()This method returns an empty set.


Collections.emptySortedMap()This method returns an empty sorted map.


Collections.emptySortedSet()This method returns an empty sorted set.


Collections.fill(List, E)This method replaces all of the elements of the specified list with the specified element.


Collections.frequency(Collection, Object)This method returns the number of elements in the specified collection equal to the specified object.


Collections.indexOfSubList(List, List)This method returns the starting position of the first occurrence of the specified target list within the specified source list, or -1 if there is no such occurrence.


Collections.lastIndexOfSubList(List, List)This method returns the starting position of the last occurrence of the specified target list within the specified source list, or -1 if there is no such occurrence.


Collections.list(Enumeration) This method returns an array list containing the elements returned by the specified enumeration in the order they are returned by the enumeration.


Collections.max(Collection)This method returns the maximum element of the given collection, according to the natural ordering of its elements.


Collections.max(Collection, Comparator)This method returns the maximum element of the given collection, according to the order induced by the specified comparator.


Collections.min(Collection)This method returns the minimum element of the given collection, according to the natural ordering of its elements.


Collections.min(Collection, Comparator)This method returns the minimum element of the given collection, according to the order induced by the specified comparator.


Collections.nCopies(int, List)This method returns an immutable list consisting of n copies of the specified object.


Collections.newSetFromMap(Map)This method returns a set backed by the specified map. The resulting set displays the same ordering, concurrency, and performance characteristics as the backing map.


Collections.replaceAll(List, E, E)This method replaces all occurrences of one specified value in a list with another.


Collections.reverse(List)This method reverses the order of the elements in the specified list.


Collections.reverseOrder()This method returns a comparator that imposes the reverse of the natural ordering on a collection of objects that implement the Comparable interface.


Collections.rotate(List, int)This method rotates the elements in the specified list by the specified distance.


Some more Methods of Collections class Part -I


Some more Methods of Collections class Part -III


No comments:

Post a Comment