Collection Framework Introduction
- The Java platform includes a collections framework.
- In the earliest Java (before Java 2), there was support for collection objects such as Dictionary, Properties, Stack, and Vector.
- These Java classes were used for the storage, manipulation, and the grouping of objects.
- A collection is an object that represents a group of objects (such as the classic Vector class).
- A collections framework is a unified architecture for representing and manipulating collections, enabling collections to be manipulated independently of implementation details.
- The Java collections framework is a robust, reliable, and high-performance mechanism.
- Examples of such Java collection interfaces and classes include dynamic arrays, linked lists, hash tables, trees, etc.
- Each data collection implements a particular algorithm such as linked list, hash set, tree set, etc., which is underlying and can be inherited by the child class.
- The collection framework has two types of components:
- Collection Interfaces
- Collection Classes
- They provide concrete implementations to the collection interfaces.
- Actually, collection classes represent reusable data structures.
- Algorithms in Java Collections Framework
- The algorithm helps implementing objects to perform basic operations, such as sorting, searching, etc.
- These algorithms are polymorphic in nature, which means that we can use the same method of implementing interface on different implementations to perform supporting operations.
- The primary advantages of a collections framework are that it:
- Reduces programming effort by providing data structures and algorithms so you don't have to write them yourself.
- Increases performance by providing high-performance implementations of data structures and algorithms. Because the various implementations of each interface are interchangeable, programs can be tuned by switching implementations.
- Provides interoperability between unrelated APIs by establishing a common language to pass collections back and forth.
- Reduces the effort required to learn APIs by requiring you to learn multiple ad hoc collection APIs.
- Reduces the effort required to design and implement APIs by not requiring you to produce ad hoc collections APIs.
- Fosters software reuse by providing a standard interface for collections and algorithms with which to manipulate them.
Tags:
Java