Collection vs Collections

Collection Interface:


Collection framework provides interfaces and classes for used to store, retrieve, manipulate the data.
In Java Collection interface is a root level interface for collection framework, which represents a group of multiple objects as a single entity.
The Iterable interface is the super interface of Collection interface and it is available in java.util package.


public interface Collection<E> extends Iterable<E>


Collection interface provides some most common methods, which are applicable to any collection object.

Such as add(), addAll(), remove(), removeAll(), retainAll(), contains(), containsAll(), clear(), size(), equals(), hashCode(), toArray(), isEmpty(), and iterator().

Collection Framework Hierarchy













Interfaces from Collection framework

Collection, List, Set, SortedSet, NavigableSet, Queue, Map, SortedMap, NavigableMap

Collections Class:


Collections is a utility class it provides several utility methods for collection objects and it is present in java.util package.
Every method is static inside Collections class.
E.g: sort(), reverse(), synchronizedList(), synchronizedMap() etc.


No comments:

Post a Comment