In Java, what is the difference between Stack and Queue?

In Java, what is the difference between Stack and Queue?

Ninja Asked on 17th September 2018 in Java.
Add Comment
1 Answer(s)
Best answer

In Java, Stack is a collection of objects that works in LIFO (Last in First out) mechanism while Queue is FIFO (First in First out).

This means that the object that is inserted first is removed last in a stack while an object that is inserted first is removed first in a queue.

Note:- Stack is deprecated and is recommended to use Deque instead.

Ninja Answered on 17th September 2018.
Add Comment