What is Collections Framework in Java?
In Java collection is an object that represents a group of objects (such as the classic Vector class). ACollections framework is a unified architecture for representing and manipulating collections, enabling collections to be manipulated independently of implementation details.
What is Collection Interface?
TheCollection interface is the foundation upon which the collections framework is built. It declares the core methods that all collections will have. It is the root interface of the Collections framework. A there is no direct implementation of the Collections Interface, it is implemented using its sub-interfaces like List, Set, Queue.
For example, the SortedSet class implements the Set interface which is a subinterface of theĀ CollectionĀ Interface.

TheĀ collection interfacesĀ are divided into two groups. The most basic interface,Ā java.util.Collection, has the following descendants:
- java.util.Set
- java.util.SortedSet
- java.util.NavigableSet
- java.util.Queue
- java.util.concurrent.BlockingQueue
- java.util.concurrent.TransferQueue
- java.util.Deque
- java.util.concurrent.BlockingDeque
- java.util.SortedMap
- java.util.NavigableMap
- java.util.concurrent.ConcurrentMap
- java.util.concurrent.ConcurrentNavigableMap
Sub Interfaces of the Collections Framework
As shown above collections framework has sub interfaces that are implemented by various classes in javaList Interface
- Elements can be accessed based on their index ( zero based indexing )
- It can contain duplicate values
- In addition to the pre defined methods of theĀ Collection framework,Ā List defines some of its own methods
Set Interface
- Set allows us to store different elements in different set, as in mathematics, it cannot have duplicate elements.
Queue Interface
- TheĀ
QueueĀ interface is used when we want to store and access elements inĀ First In, First Out(FIFO)Ā manner
Methods of Collection
TheĀCollection interface includes various methods that is used to perform different operations on objects. These methods are available in all its subinterfaces.
add()Ā - inserts the specified element to the collectionsize()Ā - returns the size of the collectionremove()Ā - removes the specified element from the collectioniterator()Ā - returns an iterator to access elements of the collectionaddAll()Ā - adds all the elements of a specified collection to the collectionremoveAll()Ā - removes all the elements of the specified collection from the collectionclear()Ā - removes all the elements of the collection