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

  1. // Copyright(c) 1996 ObjectSpace, Inc.
  2.  
  3. import jgl.*;
  4.  
  5. public class Algorithms3
  6.   {
  7.   public static void main( String[] args )
  8.     {
  9.     SList list = new SList();
  10.     list.add( new Integer( -1 ) );
  11.     list.add( new Integer( 1 ) );
  12.     list.add( new Integer( -2 ) );
  13.     list.add( new Integer( 1 ) );
  14.     list.add( new Integer( -3 ) );
  15.     System.out.println( "list = " + list );
  16.  
  17.     Object value = new Integer( 1 );
  18.     int n1 = Counting.count( list, value );
  19.     System.out.println( "Occurences of " + value + " = " + n1 );
  20.  
  21.     int n2 = Counting.countIf( list, new NegativeInteger() );
  22.     System.out.println( "Occurences of a negative = " + n2 );
  23.     }
  24.   }
  25.  
  26.