SHOW:
|
|
- or go back to the newest paste.
1 | // | |
2 | // Created by Julio Tentor <jtentor@fi.unju.edu.ar> | |
3 | // | |
4 | ||
5 | public class Demo2 { | |
6 | public void Run() { | |
7 | ||
8 | System.out.println("Demo de Stack (Estructura de Datos y Librerรญa de Java)"); | |
9 | ||
10 | Stack<Character> miPila = new Stack<Character>(); | |
11 | java.util.Stack<Character> otraPila = new java.util.Stack<Character>(); | |
12 | ||
13 | ||
14 | miPila.push('a'); | |
15 | otraPila.push('a'); | |
16 | miPila.push('b'); | |
17 | otraPila.push('b'); | |
18 | miPila.push('c'); | |
19 | otraPila.push('c'); | |
20 | ||
21 | System.out.println("miPila..: " + miPila); | |
22 | System.out.println("otraPila: " + otraPila); | |
23 | ||
24 | while (!miPila.empty()) { | |
25 | System.out.println(miPila.pop() + " - " + otraPila.pop()); | |
26 | } | |
27 | ||
28 | try { | |
29 | System.out.println(miPila.peek()); | |
30 | } catch (Exception e){ | |
31 | System.out.println(e); | |
32 | } | |
33 | ||
34 | try { | |
35 | System.out.println(otraPila.peek()); | |
36 | } catch (Exception e){ | |
37 | System.out.println(e); | |
38 | } | |
39 | ||
40 | } | |
41 | ||
42 | } | |
43 |