Advertisement
jtentor

DemoStack1 - Java - Main

May 10th, 2020
843
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.53 KB | None | 0 0
  1. public class DemoStack1 {
  2.  
  3.     public static void main(String[] args) {
  4.         System.out.println("Demo de Stack");
  5.  
  6.         Stack miPila = new Stack();
  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