You are only adding a single array, so change this:
double[][] result = Arrays.copyOf(array, array.length + value.length);
to this:
double[][] result = Arrays.copyOf(array, array.length + 1);
Every array is an object, even primitive arrays. If you were to add System.out.println(result[0].getClass().getSuperClass());
to your code, it would print class java.lang.Object
.
This means every element of 'result' is an object. When you call Arrays.copyOf and request a larger array, all of the extra elements are set to null (as specified in the Arrays.copyOf documentation).
Which means you may not legally access result[result.length - 1][i]
until you set result[result.length - 1]
to a non-null value. Specifically, you want to set it to a new double array.
In Java, all arrays have a typesafe public clone() method, so you can do away with your for-loop, and simply call:
result[result.length - 1] = value.clone();