How implementation of java.util.queue uses LIFO?
You can use any Deque as a LIFO queue using Collections.asLifoQueue method:
Queue<Integer> arrayLifoQueue = Collections.asLifoQueue(new ArrayDeque<Integer>());
Queue<Integer> linkedListLifoQueue = Collections.asLifoQueue(new LinkedList<Integer>());
You can use a java.util.LinkedList
and use the pop()
and push()
methods and use it like a stack, which is a LIFO queue.