It defines set of classes and interfaces which can be used for representing a group of objects as single entity.
Declaration of Collection interface:
Here ‘E’ specifies the type of element collection can hold.
Advantages of Collection :
-A programmer can effectively reduce the effort of programming by the help of effective algorithms and data structures provided by the framework.
-It increases program speed and quality since the implementation of each interface is interchangeable.
-It reduces the effort in designing new API.
-It encourages software reuse since the interfaces and algorithm are reuseable.
-By the help help of api programmer can achieve different operation on Collection
-The generic constructor provide type safety.
what we can do with 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
Collections come in four basic flavors:
■ Lists Lists of things (classes that implement List)(ordered).
■ Sets Unique things (classes that implement Set).
■ Maps Things with a unique ID (classes that implement Map).
■ Queues Things arranged by the order in which they are to be processed.