Collection tutorial java

Collection is a simply an object that represents a group of objects into a single unit.

Collection framework:

Collection framework is a unified architecture or a set classes and interfaces for representing and manipulating collections. i.e. collection framework is used to store, retrieve and manipulate collections.

Collection framework contains following:

  1. Interfaces: are abstract data types that represent collections and allow collections to be manipulated independently of the details of their representation.
  2. Classes/Implementations: are the concrete implementations of the collection interfaces.
  3. Algorithms: are the methods used for collection computations, like searching and sorting.

Advantages/Benefits of collection framework:

  1. Reduces programming effort: Collection framework provides useful data structure and algorithms for collection manipulation, you not have to write them.
  2. Increases program speed and quality: Collection framework provides high-performance and high-quality implementations of useful data structures and algorithms which increase the speed and quality.
  3. Resizable: Collection is resizable.
  4. Reduces effort to design new APIs: becausecollection framework eliminates the need to produce ad hoc collections APIs.

Disadvantages of collection framework:

  1. It must cast to correct type.
  2. It can’t be done compile-time type checking.

Note: Above two disadvantages can be removed from collection framework by using generics.
Core Collection Framework interfaces are categories into two sets collections and maps.
Note: Maps are not the integral part of collection framework but are considered as collection because they can store and manipulate group of objects like collections.
 

Collection tutorial:

 

Please Share