jtentor icon

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

jtentor | PRO | 09/20/20 02:15:08 PM UTC | 0 ⭐ | 2314 👁️ | Never ⏰ | []
Java |

1.02 KB

|

None

|

0 👍

/

0 👎

//
// Created by Julio Tentor <[email protected]>
//
 
public class Demo2 {
    public void Run() {
 
        System.out.println("Demo de Stack (Estructura de Datos y Librería de Java)");
 
        Stack<Character> miPila = new Stack<Character>();
        java.util.Stack<Character> otraPila = new java.util.Stack<Character>();
 
 
        miPila.push('a');
        otraPila.push('a');
        miPila.push('b');
        otraPila.push('b');
        miPila.push('c');
        otraPila.push('c');
 
        System.out.println("miPila..: " + miPila);
        System.out.println("otraPila: " + otraPila);
 
        while (!miPila.empty()) {
            System.out.println(miPila.pop() + " - " + otraPila.pop());
        }
 
        try {
            System.out.println(miPila.peek());
        } catch (Exception e){
            System.out.println(e);
        }
 
        try {
            System.out.println(otraPila.peek());
        } catch (Exception e){
            System.out.println(e);
        }
 
    }
 
}
 

Comments