home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 October A / Pcwk10a98.iso / Inprise / TRIAL / JBUILDER / JSAMPLES.Z / Applying1.java < prev    next >
Text File  |  1998-05-08  |  834b  |  31 lines

  1. // Copyright(c) 1996,1997 ObjectSpace, Inc.
  2. import com.objectspace.jgl.*;
  3. import com.objectspace.jgl.algorithms.*;
  4. import com.objectspace.jgl.functions.*;
  5.  
  6. /**
  7.  * Applying a unary function to every element of a sequence.
  8.  *
  9.  * @see com.objectspace.jgl.algorithms.Applying
  10.  * @version 3.0.0
  11.  * @author ObjectSpace, Inc.
  12.  */
  13.  
  14. public class Applying1
  15.   {
  16.   public static void main( String[] args )
  17.     {
  18.     Array array = new Array();
  19.     array.add( "cat" );
  20.     array.add( "dog" );
  21.     array.add( "emu" );
  22.     System.out.println( "array = " + array );
  23.  
  24.     System.out.println( "Print each element to standard output" );
  25.     Applying.forEach( array.begin(), array.end(), new Print() );
  26.  
  27.     System.out.println( "Print each element to standard output" );
  28.     Applying.forEach( array, new Print() );
  29.     }
  30.   }
  31.