JavaIntermediate#collections

What is the difference between Deque and Queue?

Queue supports FIFO operations (offer, poll, peek) at one end. Deque (double-ended queue) supports insertion and removal at both ends, and can be used as a Queue, Stack, or both.

Example
Deque<Integer> stack = new ArrayDeque<>();
stack.push(1); stack.push(2);
stack.pop(); // 2, LIFO behavior

Related Questions

1
JavaBeginner#collections

How do you make a collection immutable?

Open
2
JavaBeginner#collections

What is the difference between Collection and Collections?

Open
3
JavaIntermediate#generics

What is a bounded type parameter in generics?

Open