home *** CD-ROM | disk | FTP | other *** search
/ ActiveX Programming Unleashed CD / AXU.iso / jgl_1_1 / jgl_1_1.exe / examples / Iterators9.java < prev    next >
Encoding:
Java Source  |  1996-07-15  |  673 b   |  27 lines

  1. // Copyright(c) 1996 ObjectSpace, Inc.
  2. import jgl.*;
  3. import java.util.Enumeration;
  4.  
  5. public class Iterators9
  6.   {
  7.   public static void main( String[] args )
  8.     {
  9.     Array array = new Array();
  10.     array.add( "ape" );
  11.     array.add( "bat" );
  12.     array.add( "cat" );
  13.  
  14.     OutputStreamIterator output = new OutputStreamIterator( System.out );
  15.     Enumeration input = array.elements();
  16.  
  17.     while( input.hasMoreElements() )
  18.       output.put( input.nextElement() );
  19.     System.out.println(); // Flush output.
  20.  
  21.     // You can use an algorithm to do the same thing.
  22.     Copying.copy( array, output );
  23.     System.out.println(); // Flush output.
  24.     }
  25.   }
  26.  
  27.