Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- public class Pila {
- private int cont=0;
- private ArrayList<Integer>numeros=new ArrayList<Integer>();
- //Costructores
- public Pila() {
- }
- public Pila(Pila copia) {
- for(int i=0;i<copia.cont;i++) {
- numeros.add(copia.numeros.get(i));
- cont++;
- }
- }
- //Metodos
- public void Mostrar() {
- if(!EstaVacia()) {
- for (int j=0; j<cont; j++) {
- System.out.println(numeros.get(j));
- }
- }
- else {
- System.out.println("Está Vacia...");
- }
- }
- public boolean EstaVacia() {
- return cont<=0;
- }
- public void Apilar(int aux) {
- numeros.add(aux);
- cont++;
- }
- public int Desapilar() {
- cont--;
- return numeros.get(cont);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement