Advertisement
jtentor

DemoStack2 - Java - main

May 10th, 2020
864
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.55 KB | None | 0 0
  1. public class DemoStack2 {
  2.  
  3.     public static void main(String[] args) {
  4.         System.out.println("Demo de Stack");
  5.  
  6.         Stack<Character> miPila = new Stack<Character>();
  7.  
  8.         miPila.push('a');
  9.         miPila.push('b');
  10.         miPila.push('c');
  11.  
  12.         System.out.println(miPila.pop());
  13.         System.out.println(miPila.pop());
  14.         System.out.println(miPila.pop());
  15.  
  16.         try {
  17.             System.out.println(miPila.peek());
  18.         } catch (Exception e){
  19.             System.out.println(e.getMessage());
  20.         }
  21.  
  22.     }
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement