import java.util.Stack; public class Demo { public static void main(String args[]) { Stack<Integer> stack = new Stack<>(); stack.push(10); stack.push(20); stack.push(30); stack.push(40); stack.push(50); System.out.println("The stack elements are: " + stack); System.out.println("The element that was popped is: " + stack.pop()); System.out.println("The stack elements are: " + stack); } }