This article provides a comprehensive overview of Java Collections Framework (JCF) which is used by many developers to write java programs.
Contents
What is Java Collections Framework?
In order to write efficient programs you need to know how to work with a data structure. A data structure is a entity which contains a group of data organized in some manner. Examples of popular data structures are arrays, stacks, queues, linked lists, trees, etc.
Java provides many data structures. The data structure framework or library provided by Java is known as the Java Collections Framework (JCF). Java defines a collection as an object that represents a group of objects.
The collections framework is a standard way for representing and manipulating collections. It contains the following components:
- Interfaces: These are abstract data types that represent collections. Interfaces allow collections to be manipulated independently of the details of their representation. In object-oriented languages, interfaces generally form a hierarchy.
- Classes: These are the concrete implementations of the collection interfaces. In essence, they are reusable data structures.
- Algorithms: These are the methods that perform useful computations, such as searching and sorting, on objects that implement collection interfaces. The algorithms are said to be polymorphic: that is, the same method can be used on many different implementations of the appropriate collection interface. In essence, algorithms are reusable functionality.
What Can I Do with a Collection?
- Add objects to the collection.
- Remove objects from the collection.
- Find out if an object (or group of objects) is in the collection.
- Retrieve an object from the collection (without removing it).
- Iterate through the collection, looking at each element (object) one after another.
Goals of Java Collections Framework
The collections framework was designed to meet the following goals:
- The framework had to be high-performance. The implementations for the fundamental collections (dynamic arrays, linked lists, trees, and hash tables) are highly efficient.
- The framework had to allow different types of collections to work in a similar manner and with a high degree of interoperability.
- Extending and/or adapting a collection had to be easy.
Interfaces in Java Collections Framework
Following is the Java Collections Framework hierarchy:
Following are various interfaces available in Java Collections Framework:
Classes in Java Collections Framework
Following are various classes available in Java Collections Framework:
Suryateja Pericherla, at present is a Research Scholar (full-time Ph.D.) in the Dept. of Computer Science & Systems Engineering at Andhra University, Visakhapatnam. Previously worked as an Associate Professor in the Dept. of CSE at Vishnu Institute of Technology, India.
He has 11+ years of teaching experience and is an individual researcher whose research interests are Cloud Computing, Internet of Things, Computer Security, Network Security and Blockchain.
He is a member of professional societies like IEEE, ACM, CSI and ISCA. He published several research papers which are indexed by SCIE, WoS, Scopus, Springer and others.
Java Collection framework is a very popular framework of Java which provides a strong architecture to store or easily control the group of objects. For the purpose of better understanding.
aahan