Java – Stack (Collections Framework)
Stack: A last-in-first-out (LIFO) data structure. Allows push, pop, and peek operations.
Example:
import java.util.Stack;
Stack stack = new Stack<>();
stack.push(10);
stack.push(20);
stack.push(30);
System.out.println(stack);
System.out.println("Peek: " + stack.peek());
System.out.println("Pop: " + stack.pop());
System.out.println(stack);
No images available.