Menu

Post image 1
Post image 2
Post image 3
1 / 3
0

#39 LinkedList implements Queue

DEV Community·Deepikandas·21 days ago
#wYteQRcD
Reading 0:00
15s threshold

Deepikandas

Hierarchy
Collection Interface

Queue Interface

Deque Interface

LinkedList class
Declaration as Queue

Queue q = new LinkedList();

Enter fullscreen mode Exit fullscreen mode

Queue does NOT support indexing
So these are invalid concepts for Queue:
❌get(0)
❌add(2, value)
❌remove(1)
Queues work only:
front insertion/removal
FIFO operations
You process elements sequentially.
You don't jump to middle positions.

Queue Operations
Method ** Purpose**
add() Insert element
offer() Insert safely
poll() Remove first element
remove() Remove first element
peek() View first element
element() View first element

Read More