Advertisement
jtentor

Stack (en Java) de Estructura de Datos - Demo1.java

Sep 20th, 2020
1,472
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.61 KB | None | 0 0
  1. //
  2. // Created by Julio Tentor <jtentor@fi.unju.edu.ar>
  3. //
  4.  
  5. public class Demo1 {
  6.  
  7.     public void Run() {
  8.  
  9.         System.out.println("Demo de Stack (Estructura de Datos)");
  10.  
  11.         Stack<Character> miPila = new Stack<Character>();
  12.  
  13.         miPila.push('a');
  14.         miPila.push('b');
  15.         miPila.push('c');
  16.  
  17.         System.out.println("miPila: " + miPila);
  18.  
  19.         while (!miPila.empty()) {
  20.             System.out.println(miPila.pop());
  21.         }
  22.  
  23.         try {
  24.             System.out.println(miPila.peek());
  25.         } catch (Exception e){
  26.             System.out.println(e);
  27.         }
  28.     }
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement