SHOW:
|
|
- or go back to the newest paste.
| 1 | // | |
| 2 | // Created by Julio Tentor <[email protected]> | |
| 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 |