package asd_library.stack;

import java.util.*;

/**
 * Main class to show queue use.
 */

class StackDemo{

  /**
   * Calls the constructor and some methods
   * @param args
   */
  public static void main (String args[]){
    Stack s1 = new Stack();
    Stack s2;

    System.out.println("Stack Demo:");
    System.out.println("s1 "+  s1);

    for(int i = 1; i<10; i++){
      s1.push(new Integer(i));
    }
    s2 = (Stack)s1.clone();

    System.out.println("Stack Representation: last item at the head, first item at the end");
    System.out.println("s1 "+  s1);
    System.out.println("s2 "+  s2);
    System.out.println("s1.equals(s2): "+s1.equals(s2));
    System.out.print("s1==s2: ");System.out.println(s1==s2);
    System.out.println("last element in q1: "+s1.pop());
    System.out.println("s1 "+  s1);
    System.out.println("s2 "+  s2);
    System.out.println("s1.equals(s2): "+s1.equals(s2));

    System.out.print("Use Of ListIterator on s2: ");
    ListIterator li= s2.listIterator();
    while(li.hasNext())
      System.out.print(li.next()+ " ");


  }
}



 


Bacheca di Algoritmi e Strutture Dati a.a. 2007-08 - canale A - L

forum del corso

ultima modifica: 03/04/2008 23.35
by FdA