Collection
Framework in java
The Collection Framework
provides a well-designed set of interfaces and classes for storing
and manipulating groups of data as a single unit called a
collection.
Collection
Framework contains the following:-
- Interfaces:- These are abstract data types that represent collections. It contains abstract method that are used to for various collection operation
- Classes:- These are the implementation of the collection interfaces. This classes implements the collection interface and define the funtioning of method.
- Algorithum:- These are methods that perform useful computations , such as searching and sorting or objects that implements collection interfaces.
Features of Collection
Framework:-
- Represent group of values as a single entity.
- Size expandable – we expand size of collection at runtime.
- Homogeneous & Hetrogeneous data (we can make collection of int,float data in a single collection).
Difference between Array
and Collection:-
Array
|
Collection
|
We cannot
expand the size of array
|
We can
expand the size of colleciton
|
It takes
less time in execution
|
It takes
more time than array
|
If the size
of array is known then array is better choice
|
If the size
of array is unknown then collection is better choice
|
Interfaces in Collection
Framework:-
1. Collection:-
1. Collection:-
- It is used for grouping of object.
- It is a root interface for all other collection Framework except Map interface.
- No class can directly implement collection interface. A child interface of collection interface is used for implementing methods of collection interface.
2.List:-
- It is child interface of collection interface.
- It allows duplication or repetation of data in collection.
- Insertion order must be preserved in List interface.
- Array List, Linked List, Vector, Stack are the implementaion classes of List interface.
- Duplication is not allowed.
- Insertion order is not preserved.
- HashSet, Linked Hash Set are the implementation classes of set.
- Sorted Set and Navigable Set are child interface of Set. Tree Set is implementation class of Navigable set.
- It is child interface of collection interface.
- Priority Queue, Blocking Queue, Linked Blocking Queue,Priority Blocking Queue are implementation classes of Queue interface.
- Map is not a child interface of collection.
- It is used to represent group of object as key,value pairs.
- Key and values both are object.
- Keys must be unique but values can repeat.
- Hash Map, Linked Hash Map, Weak Hash Map,Identity Hash Map, Hashtable, Properties are implementation classes of Map.
- Sorted map and Navigable Map are the child interface of Map.
0 Comments