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 / Array4.java < prev    next >
Encoding:
Java Source  |  1997-03-14  |  943 b   |  35 lines

  1. // Copyright(c) 1996,1997 ObjectSpace, Inc.
  2.  
  3. import COM.objectspace.jgl.*;
  4.  
  5. /**
  6.  * Reserving capacity.
  7.  *
  8.  * @see COM.objectspace.jgl.Array
  9.  * @version 2.0.2
  10.  * @author ObjectSpace, Inc.
  11.  */
  12.  
  13. public class Array4
  14.   {
  15.   public static void main( String[] args )
  16.     {
  17.     Object ints[] = { "bat", "cat", "dog" };
  18.     Array array = new Array( ints );
  19.     array.put( 1, "CAT" );
  20.     System.out.println( "array = " + array + ", capacity = " + array.capacity() );
  21.     System.out.print( "array = " );
  22.     for ( int i = 0; i < ints.length; i++ )
  23.       System.out.print( ints[ i ] + " " );
  24.     System.out.println();
  25.  
  26.     array.ensureCapacity( 100 );
  27.     array.put( 2, "DOG" );
  28.     System.out.println( "array = " + array + ", capacity = " + array.capacity() );
  29.     System.out.print( "array = " );
  30.     for ( int i = 0; i < ints.length; i++ )
  31.       System.out.print( ints[ i ] + " " );
  32.     System.out.println();
  33.     }
  34.   }
  35.