Collection is a top level interface of java collection framework where as Collections is an utility class.
Collection : The root interface of Java Collections Framework.
Collection is an interface containing List, Set and Queue.
Collections : A utility class that is a member of the Java Collections Framework.
Collections is a class containing useful methods like Collections.sort() and Collections.synchronizedlist(), etc.
Collection is a root level interface of the Java Collection Framework. Most of the classes in Java Collection Framework inherit from this interface. List, Set and Queue are main sub interfaces of this interface.
Map interface, which is also a part of java collection framework, doesn’t inherit from Collection interface. Collection interface is a member of java.util package.
Collections is an utility class in java.util package. It consists of only static methods which are used to operate on objects of type Collection.
Collections.max() This method returns maximum element in the specified collection.
Collections.min() This method returns minimum element in the given collection.
Collections.sort() This method sorts the specified collection.
Collections.shuffle() This method randomly shuffles the elements in the specified collection.
Collections.synchronizedCollection() This method returns synchronized collection backed by the specified collection.
Collections.binarySearch() This method searches the specified collection for the specified object using binary search algorithm.
Collections.disjoint() This method returns true if two specified collections have no elements in common.
Collections.copy() This method copies all elements from one collection to another collection.
Collections.reverse() This method reverses the order of elements in the specified collection.
No comments:
Post a Comment