FileDocCategorySizeDatePackage
SampleCreateArray.javaAPI DocExample1681Tue Dec 12 18:58:50 GMT 2000None

SampleCreateArray

public class SampleCreateArray extends Object

Fields Summary
Constructors Summary
Methods Summary
static java.lang.ObjectdoubleArray(java.lang.Object source)

      int sourceLength = Array.getLength(source);
      Class arrayClass = source.getClass();
      Class componentClass = arrayClass.getComponentType();
      Object result = Array.newInstance(componentClass, sourceLength * 2);     
      System.arraycopy(source, 0, result, 0, sourceLength);
      return result;
   
public static voidmain(java.lang.String[] args)

      int[] originalArray =  {55, 66};
      int[] biggerArray = (int[]) doubleArray(originalArray);
      System.out.println("originalArray:");
      for (int k = 0; k < Array.getLength(originalArray); k++)
         System.out.println(originalArray[k]);
      System.out.println("biggerArray:");
      for (int k = 0; k < Array.getLength(biggerArray); k++)
         System.out.println(biggerArray[k]);