Programming |
Collection(I)
Collection interface is used to represent a group of individual objects as a single entity. Collection is the root interface of the collection framework. All the interfaces like List, Set, Map etc in the collection framework extend this interface. This interface defines common methods for handling basic operations for every collection.
Collections(C)
Collections is a utility class which defines different utility methods for manipulating a Collection. This class is available in java.util package.
Method |
Description |
sort(List<T> list) |
Sorts the specified list into ascending order, according to the natural ordering of its elements |
sort(List<T> list, Comparator<? super T> c) |
Sorts the specified list according to the order induced by the specified comparator |
swap(List<?> list, int i, int j) |
Swaps the elements in the specified list |
synchronizedCollection(Collection<T> c) |
Method to get synchronized (thread-safe) collection |
reverse(List<?> list) |
Reverses the order of the elements in the specified list |
shuffle(List<?> list) |
Randomly shuffles the specified list |
Collection framework:
Collection Framework is a concept which deals with everything related to collection. It’s a group of classes and interfaces that can be used to represent a collection and perform various operations as per the requirement of the user. Both Collection(I) interface and Collections(C) class come within Collection Framework.