Skip to content
Sean Raven edited this page Oct 28, 2015 · 1 revision

A Stack is a last-in, first-out (LIFO) structure. It is used by certain algorithms which must process the most recently encountered items first.

Java does not directly support stacks (there is a Stack class, but it is deprecated). Instead, there is a function to convert an ArrayDeque into a stack.

  • C++ stack
  • Java: Queue<Integer> stack = Collections.asLifoQueue(new ArrayDeque<Integer>());

Clone this wiki locally