public class ResizeArrayExercise {
  public static int[] resize(int[] A, int newLen) {
    if (newLen <= 0) {
      return null;
    }

    /* 1) make a new array that's of length newLen */
    int []B = new int[newLen];
		
    /* How many elements should we copy? */
    int numToCopy = Math.min(newLen, A.length);

    //        if (newLen < A.length) {
    //        	numToCopy = newLen;
    //        } else {
    //        	numToCopy = A.length;
    //        }
		
    /* 2) copy the contents of the original array into the new one */
    for (int i = 0; i < numToCopy; i++) {
      B[i] = A[i];
    }
		
    /* 3) return the location of the new array */
    return B;
  }
}
