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

  1. // Copyright(c) 1997 ObjectSpace, Inc.
  2. import com.objectspace.jgl.*;
  3. import com.objectspace.jgl.algorithms.*;
  4. import com.objectspace.jgl.functions.*;
  5.  
  6. /**
  7.  * Calculate and sum the difference between adjacent pairs of values.
  8.  *
  9.  * @see com.objectspace.jgl.algorithms.Counting
  10.  * @version 3.0.0
  11.  * @author ObjectSpace, Inc.
  12.  */
  13.  
  14. public class Counting5
  15.   {
  16.   public static void main( String[] args )
  17.     {
  18.     Array array = new Array();
  19.     for ( long i = 1; i <= 10; ++i )
  20.       array.add( new Long( i ) );
  21.     System.out.println( array );
  22.  
  23.     Array result = new Array();
  24.     Counting.adjacentDifference
  25.       (
  26.       array,
  27.       result,
  28.       new TimesNumber( Long.class )
  29.       );
  30.     System.out.println( result );
  31.     }
  32.   }
  33.