In Java, what is the difference between Stack and Queue?
Answered
In Java, what is the difference between Stack and Queue?
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.