Collection in java can be called as a container, or an object which binds multiple elements into a single unit.
Collections in java is a framework used to store, and manipulate group of elements. They represent data items that form a group on which operations such as searching, sorting, insertion, manipulation, deletion etc can be performed to manipulate data.
Collections Framework has:
- Interfaces and its implementations i.e. classes
- Algorithm
The Hierarchy of the Collection Framework
1. Iterate
2. Collection
3. List
(i) ArrayList,
(II) Vector,
(III) LinkedList,
(Iv) PriorityQueue,
(v) HashSet,
(vi) LinkedHashSet,
(vii) TreeSet etc
4.Queue
(i) List,
(ii) Queue,
(iii)Deque
5. Sets
(i)HashSet
(ii)LinkedHashSet
(iii)SortedSet
(iv)TreeSet
There are methods of Collection interface
- public boolean add(Object element),
- public boolean addAll(collection c),
- public boolean remove(Object element),
- public boolean removeAll(Collection c),
- public boolean retainAll(Collection c) etc
But only three methods are there for Iterator interface.
- public boolean hasNext().
- public object next().
- public void remove().
0 Comment(s)