home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-09-10 | 942 b | 40 lines |
- // Copyright(c) 1996 ObjectSpace, Inc.
-
- import java.util.Enumeration;
- import jgl.*;
-
- /**
- * Construction, enumeration, pushing, popping.
- * <p>
- * @see jgl.Stack
- * @version 1.1
- * @author ObjectSpace, Inc.
- */
-
- public class Stack1
- {
- public static void main( String[] args )
- {
- // Use an Slist as the underlying data structure.
- Stack stack = new Stack();
- stack.push( "bat" );
- stack.push( "cat" );
- stack.push( "dog" );
-
- System.out.println( "Print the Stack." );
- System.out.println( stack );
- System.out.println();
-
- System.out.println( "Non-destructively enumerate the Stack." );
- Enumeration e = stack.elements();
- while( e.hasMoreElements() )
- System.out.println( e.nextElement() );
- System.out.println();
-
- System.out.println( "Pop and print each element." );
- while( !stack.isEmpty() )
- System.out.println( stack.pop() );
- }
- }
-
-