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

  1. // Copyright(c) 1996,1997 ObjectSpace, Inc.
  2. import com.objectspace.jgl.*;
  3.  
  4. public class Sequences5
  5.   {
  6.   public static void main( String[] args )
  7.     {
  8.     String strings1[] = { "ape", "bat", "cat" };
  9.     Array array = new Array( strings1 );
  10.  
  11.     System.out.print( "array = " + array + ", size = " + array.size() );
  12.     System.out.println( ", capacity = " + array.capacity() );
  13.  
  14.     array.put( 2, "CAT" );
  15.     System.out.println( "array = " + array );
  16.     System.out.print( "Original = " );
  17.     for ( int i = 0; i < strings1.length; i++ )
  18.       System.out.print( strings1[ i ] + " " );
  19.     System.out.println();
  20.  
  21.     array.add( "dog" ); // Forces reallocation of storage.
  22.     System.out.print( "array = " + array + ", size = " + array.size() );
  23.     System.out.println( ", capacity = " + array.capacity() );
  24.     System.out.print( "Original = " );
  25.     for ( int i = 0; i < strings1.length; i++ )
  26.       System.out.print( strings1[ i ] + " " );
  27.     System.out.println();
  28.  
  29.     String string2[] = new String[ array.size() ];
  30.     array.copyTo( string2 ); // Copy contents of array into native array.
  31.  
  32.     for ( int i = 0; i < string2.length; i++ )
  33.       System.out.print( string2[ i ] + " " );
  34.     System.out.println();
  35.     }
  36.   }
  37.