3 Goonj 4 43242 Invstigacion
3 Goonj 4 43242 Invstigacion
3 Goonj 4 43242 Invstigacion
Java collections
Java Collections can achieve all the operations that you perform on a data such as
searching, sorting, insertion, manipulation, and deletion.
Java Collection means a single unit of objects. Java Collection framework provides
many interfaces (Set, List, Queue, Deque) and classes (ArrayList, Vector, LinkedList,
PriorityQueue, HashSet, LinkedHashSet, TreeSet).
Do You Know?
o What are the two ways to iterate the elements of a collection?
o What is the difference between ArrayList and LinkedList classes in collection
framework?
o What is the difference between ArrayList and Vector classes in collection
framework?
o What is the difference between HashSet and HashMap classes in collection
framework?
o What is the difference between HashMap and Hashtable class?
o What is the difference between Iterator and Enumeration interface in collection
framework?
o How can we sort the elements of an object? What is the difference between
Comparable and Comparator interfaces?
o What does the hashcode() method?
o What is the difference between Java collection and Java collections?
next →← prev
Collections in Java
Collection interface
Iterator interface
Java Collections can achieve all the operations that you perform on a data
such as searching, sorting, insertion, manipulation, and deletion.
It is optional.
Algorithm
Do You Know?
How can we sort the elements of an object? What is the difference between
Comparable and Comparator interfaces?
There are many methods declared in the Collection interface. They are as
follows:
8 public void clear() It removes the total number of elements from the
collection.
Iterator interface
There are only three methods in the Iterator interface. They are:
2 public Object next() It returns the element and moves the cursor
pointer to the next element.
Iterable Interface
The Iterable interface is the root interface for all the collection classes. The
Collection interface extends the Iterable interface and therefore all the
subclasses of Collection interface also implement the Iterable interface.
Iterator<T> iterator()
Collection Interface
Some of the methods of Collection interface are Boolean add ( Object obj),
Boolean addAll ( Collection c), void clear(), etc. which are implemented by all
the subclasses of Collection interface.
List Interface
There are various methods in List interface that can be used to insert,
delete, and access the elements from the list.
The classes that implement the List interface are given below.
gewfwe
wegwe
gewf