public class StackExample
{
// Ignore args
public static void main(String[] args)
{
ArrayStack<Integer> stack1=new ArrayStack<Integer>();
LinkedStack<Integer> stack2=new LinkedStack<Integer>();

// stack 1 manipulations
System.out.format("\n---------------------------------------\n");
System.out.format("stack1 contents as individually pushed:\n");
for(int i=0;i<10;i++)
   {
   System.out.format("%3d ",i);
   stack1.push(i);
   }
System.out.format("\n");

System.out.format("Integer on top of stack1 is: %d\n",stack1.peek());
System.out.format("%d integers have been pushed on stack1\n",stack1.size());
System.out.format("Contents of stack1 via toString:\n%s\n",stack1.toString());
 
System.out.format("\nContents individuually popped off:\n");
while(!stack1.isEmpty())
   {
   System.out.format("%3d ",stack1.pop());
   }
if(stack1.isEmpty()) System.out.format("\nstack1 is now empty\n\n"); 

// Do the same thing to stack2 (now the implementation is a linked list)
System.out.format("\n---------------------------------------\n");
System.out.format("stack2 contents as individually pushed:\n");
for(int i=9;i>=0;i--)
   {
   System.out.format("%3d ",i);
   stack2.push(i);
   }
System.out.format("\n");

System.out.format("Integer on top of stacks2 is: %d\n",stack2.peek());
System.out.format("%d integers have been pushed on stack2\n",stack2.size());
System.out.format("Contents of stack2 via toString:\n%s\n",stack2.toString());
 
System.out.format("\nContents individuually popped off:\n");
while(!stack2.isEmpty())
   {
   System.out.format("%3d ",stack2.pop());
   }
if(stack1.isEmpty()) System.out.format("\nstack2 is now empty\n\n");
}
}
