Advertisement
jtentor

DemoStack3 - Java - main

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