home *** CD-ROM | disk | FTP | other *** search
/ ActiveX Programming Unleashed CD / AXU.iso / jgl_1_1 / examples / iterators3.java < prev    next >
Encoding:
Java Source  |  1996-07-14  |  641 b   |  26 lines

  1. // Copyright(c) 1996 ObjectSpace, Inc.
  2. import jgl.*;
  3.  
  4. public class Iterators3
  5.   {
  6.   public static void main( String[] args )
  7.     {
  8.     Array array = new Array();
  9.     array.add( "ape" );
  10.     array.add( "giraffe" );
  11.     array.add( "lizard" );  
  12.     System.out.println( "array = " + array );
  13.  
  14.     // Obtain iterator positioned "just-past-the-end".
  15.     ArrayIterator iterator = array.end();
  16.  
  17.     // Obtain iterator positioned at first element.
  18.     ArrayIterator begin = array.begin();
  19.  
  20.     while( !iterator.equals( begin ) )
  21.       {
  22.       iterator.retreat();
  23.       System.out.println( iterator.get() );
  24.       }
  25.     }
  26.   }