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

  1. // Copyright(c) 1996,1997 ObjectSpace, Inc.
  2. import com.objectspace.jgl.*;
  3. import com.objectspace.jgl.adapters.*;
  4. import com.objectspace.jgl.algorithms.*;
  5. import com.objectspace.jgl.predicates.*;
  6.  
  7. /**
  8.  * Finding provides algorithms for locating elements in a container.
  9.  *
  10.  * @see com.objectspace.jgl.algorithms.Finding
  11.  * @version 3.0.0
  12.  * @author ObjectSpace, Inc.
  13.  */
  14.  
  15. public class Algorithms4
  16.   {
  17.   public static void main( String[] args )
  18.     {
  19.     int ints[] = { 3, 7, 8, 2, -5, 8, 9, -2 };
  20.     IntArray array = new IntArray( ints );
  21.     System.out.println( "array = " + array );
  22.  
  23.     Integer negative = (Integer)Finding.detect( array, new NegativeNumber() );
  24.     System.out.println( "first negative = " + negative );
  25.  
  26.     boolean some = Finding.some( array, new NegativeNumber() );
  27.     System.out.println( "some items are negative = " + some );
  28.     }
  29.   }
  30.