Advertisement
jtentor

DemoStack2 - Java - main

May 10th, 2020
773
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement