DEV Community

Indumathy
Indumathy

Posted on

Collection

Java Collection Framework:

The Java Collection Framework is a predefined architecture that helps developers store and manipulate groups of objects efficiently.
It provides ready-made classes, interfaces, and methods to manage data easily.

What is a Framework?

A framework is a predefined structure that provides ready-made tools, libraries, and classes to help developers build applications faster and more efficiently.

Benefits of Framework

Reusable packages and classes
Reduces development time
Improves code organization

Java Collection Framework

The Collection Framework in Java is used to store and manipulate groups of objects as a single unit.
It is available in the java.util package:

Collection Interfaces Structure

The main interfaces in the Java Collection Framework are:

Collection
|
|--- List
| |--- ArrayList
| |--- LinkedList
| |--- Vector
|
|--- Set
| |--- HashSet
| |--- TreeSet
| |--- LinkedHashSet
|
|--- Queue
|--- PriorityQueue
|--- LinkedList

List Interface

The List interface is part of the java.util package.

Features of List

Allows duplicate values
Maintains insertion order
Allows index-based operations
We cannot create objects directly for List because it is an interface.

Common Methods
add()
get()
remove()
size()

Set Interface

The Set interface stores unique elements.

Features

Does not allow duplicate values
Does not maintain insertion order (in HashSet)
Does not support index-based operations

Implementations
HashSet
TreeSet
LinkedHashSet

Queue Interface

The Queue interface follows the FIFO principle.
FIFO = First In First Out
This means the first element inserted will be the first element removed.

Implementations:
PriorityQueue
LinkedList

Top comments (0)