Java Collections
Java Collections
Java
Collections in Java
• The Collections in Java is a framework that provides an architecture to store and
manipulate the group of objects
• Java Collections can achieve all the operations that you perform on a data such
as searching, sorting, insertion, manipulation, and deletion
• Java Collection framework provides many interfaces (e.g., Set, List, Queue,
Deque) and classes (e.g., ArrayList, LinkedList, PriorityQueue, HashSet,
LinkedHashSet, TreeSet)
What is a framework in Java
• It provides readymade architecture
• It is optional
What is a Collection framework?
The Collection framework represents a unified architecture for storing and
manipulating a group of objects.
It has:
• Interfaces and its implementations, i.e., classes
• Algorithm
Iterable Interface
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
• In other words, we can say that the Collection interface builds the foundation on
which the collection framework depends
Methods of Collection Interface
No. Method Description
• It inhibits a list type data structure in which we can store the ordered collection
of objects
• It uses dynamic array to store the duplicate element of different data types
• A Map is useful if you must search, update, or delete elements based on a key
Java Map Hierarchy
• There are two interfaces for
implementing Map in Java: Map and
SortedMap, and three classes:
HashMap, LinkedHashMap and
TreeMap
LinkedHashMap
• LinkedHashMap is the implementation of Map
• It inherits HashMap class
• It maintains insertion order
TreeMap
• TreeMap is the implementation of Map
• It maintains ascending order
Useful methods of Map interface
No. Method Description