Advertisement
Aldin_SXR

stack main()

Mar 4th, 2024
419
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.45 KB | None | 0 0
  1. public static void main(String[] args) {
  2.     /* Stack demo */
  3.     Stack<Integer> stack = new Stack<>();
  4.  
  5.     stack.push(2);
  6.     stack.push(8);
  7.     stack.push(5);
  8.  
  9.     System.out.println("Stack demo: ");
  10.     System.out.println("peek: " + stack.peek());
  11.     System.out.println(stack.pop());
  12.     System.out.println(stack.pop());
  13.     System.out.println(stack.pop());
  14.  
  15.     stack.push(10);
  16.     System.out.println("stack size: " + stack.size());
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement