FileDocCategorySizeDatePackage
Stacks.javaAPI DocExample3057Mon Apr 06 18:10:24 BST 1998None

Stacks

public class Stacks extends Object

Fields Summary
static String[]
months
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

       
    Stack stk = new Stack();
    for(int i = 0; i < months.length; i++)
      stk.push(months[i] + " ");
    System.out.println("stk = " + stk);
    // Treating a stack as a Vector:
    stk.addElement("The last line");
    System.out.println(
      "element 5 = " + stk.elementAt(5));
    System.out.println("popping elements:");
    while(!stk.empty())
      System.out.println(stk.pop());