The java.util.Stack class is a Collection that behaves in a last-in-first-out (LIFO) manner.
import java.util.Stack; public class MainClass { public static void main (String args[]) { Stack s = new Stack(); s.push("A"); s.push("B"); s.push("C"); System.out.println(s); } }
[A, B, C]