home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Extras / OSpace / jgl.exe / jgl_2_0 / examples / Counting4.java < prev    next >
Encoding:
Java Source  |  1997-03-14  |  633 b   |  27 lines

  1. // Copyright(c) 1997 ObjectSpace, Inc.
  2.  
  3. import COM.objectspace.jgl.*;
  4.  
  5. /**
  6.  * Calculate and sum the difference between adjacent pairs of values.
  7.  *
  8.  * @see COM.objectspace.jgl.Counting
  9.  * @version 2.0.2
  10.  * @author ObjectSpace, Inc.
  11.  */
  12.  
  13. public class Counting4
  14.   {
  15.   public static void main( String[] args )
  16.     {
  17.     Array array = new Array();
  18.     for ( int i = 0; i < 10; ++i )
  19.       array.add( new Integer( i * i ) );
  20.     System.out.println( array );
  21.  
  22.     // note that this writes over the original array
  23.     Counting.adjacentDifference( array, array.start() );
  24.     System.out.println( array );
  25.     }
  26.   }
  27.