This method is supposed to set a value in an array, given its index. The error is an ArrayIndexOutOfBoundsException, which occurs on the line:
GrowingArray [index] = value;
However, I've done some research and using array [index] = value seems to be a legitimate way to set a value in an array. A pointer in the right direction would be helpful.
public void set (int index, int value) {
if (index <= GrowingArray.length) {
GrowingArray[index] = value;
} else {
int [] destination = new int [12/10*GrowingArray.length];
destination [index] = value;
System.arraycopy(destination, 0, GrowingArray, 0, destination.length);
}
}