Java collection framework
Before explaining the Collection framework, it is important to understand the difference among the collection, Collection and collections terminologies in the Java language.
- The collection that starts with the lowercase ‘c’, stands for any data structure where objects can be stored and iterated.
- The Collection (starting with ‘C’) is an interface of java.util package (java.util.Collection). The interfaces, Set, List and Queue are extended from the Collection.
- Collections Java is the class of java.util package. It holds utility methods to be used with collections.
The Collection framework in Java
The Collection framework is a unified architecture that stores and manipulates a group of objects. You can add, remove, search objects in the collection.
The Java Collection framework was developed to achieve certain goals like fundamental collections e.g. dynamic arrays, hashtables, trees etc to be highly efficient, to be able to work for different collections in a similar manner.
Otherwise, before Java 2 edition there were ad hoc classes like the Vector, Stack etc. to store and manipulate the group of objects. However, the way of working on those were different.
The Collection framework has
Key Interfaces and Classes of Collection in Java
A few of the common Java collection interfaces are:
- List interface
- Map interface
- The Enumeration
A few common collection classes are: