The Collection interface (java.util.Collection) and Map interface (java.util.Map) are the two main “root” interfaces of Java collection classes.
Java Collections can achieve all the operations that you perform on a data such as searching, sorting, insertion, manipulation, and deletion.
Java Collection means a single unit of objects. Java Collection framework provides many interfaces (Set, List, Queue, Deque) and classes (ArrayList, Vector, LinkedList, PriorityQueue, HashSet, LinkedHashSet, TreeSet).
What is a framework in Java
-
It provides readymade architecture.
-
It represents a set of classes and interfaces.
-
It is optional.
Collections are like containers that group multiple items in a single unit. For example, a jar of chocolates, list of names, etc.
Collections are used in every programming language and when Java arrived, it also came with few Collection classes – Vector, Stack, Hashtable, Array.
This framework has several useful classes which have tons of useful functions which makes a programmer task super easy.
A Java collection framework provides an architecture to store and manipulate a group of objects. A Java collection framework includes the following:
-
Interfaces
-
Classes
-
Algorithm
Let’s learn about them in detail:
Interfaces: Interface in Java refers to the abstract data types. They allow Java collections to be manipulated independently from the details of their representation. Also, they form a hierarchy in object-oriented programming languages.
Classes: Classes in Java are the implementation of the collection interface. It basically refers to the data structures that are used again and again.
Algorithm: Algorithm refers to the methods which are used to perform operations such as searching and sorting, on objects that implement collection interfaces. Algorithms are polymorphic in nature as the same method can be used to take many forms or you can say perform different implementations of the Java collection interface.
The Java collection framework provides the developers to access prepackaged data structures as well as algorithms to manipulate data.