public static int[] expand(int[] field,int newSize,boolean keepData){
  if (field == null || field.length < newSize) {
    int[] newArray=new int[newSize];
    if (keepData && field != null) {
      System.arraycopy(field,0,newArray,0,field.length);
    }
    return newArray;
  }
  return field;
}

public static int [ ] expand ( int [ ] field , int newSize , boolean keepData ) { if ( field == null || field . length < newSize ) { int [ ] newArray = new int [ newSize ] ; if ( keepData && field != null ) { System . arraycopy ( field , 0 , newArray , 0 , field . length ) ; } return newArray ; } return field ; }
this method will return a new allocated array of size newsize if newsize is greater than field . length . it will return the same array otherwise only if keepdata is set to true , the data of the array will be copied to the new allocated array
