In this section, you will learn the advantages and disadvantages of Java Collection Framework. A collection is simply an object that groups multiple elements into a single unit. It is also called as a container sometimes.
Advantages and Disadvantages of the Collection Framework
In this section, you will learn the advantages and disadvantages of Java Collection Framework. A collection is simply an object that groups multiple elements into a single unit. It is also called as a container sometimes. It is used to store, retrieve, manipulate, and communicate aggregate data. Typically, it represents data items that form a natural group and allows duplicate elements while others do not. It consists of both ordered and unordered elements.
Advantages of collections framework:
- We
need not to learn multiple ad hoc collection APIs.
- It
provides a standard interface for collections that fosters software reuse
and also provides algorithms to manipulate them.
- Reduces
the effort required to design and implement APIs by eliminating the need to
produce ad hoc collections APIs.
- It
provides useful data structures and algorithms that reduces programming
effort due to which we need not to write them ourselves.
- It provides high-performance implementations of useful data structures and algorithms that increases the performance.
- Helps in establishing a common language to pass collections back and forth that provides interoperability between unrelated APIs.
- Collection is resizable and can grow.
Disadvantages of collections framework:
- It must cast to correct type.
- It can't be done compile-time type checking.