I would do it like this
int[][] x1 = {{1,2,3},{1,2,3}};
int[][] x2 = {{4,5,6},{4,5,6}};
int[][] x = new int[x1.length+x2.length][];
int ix = 0;
for(int i = 0; i < x1.length; i++) x[ix++] = x1[i].clone();
for(int i = 0; i < x2.length; i++) x[ix++] = x2[i].clone();
The clone method creates a copy of an array. A two dimensional array is an array of one dimensional arrays. If I copy it I must make sure to also copy the arrays contained inside. Otherwise a change to one of the two arrays will automatically change both arrays.
e.g.
int[][] x = {{1,2,3},{1,2,3}};
int[][] y = x.clone();
x[0][0] = 7;
System.out.println(y[0][0]);
This would print out 7 because y[0] is an array and that array is not a copy of x[0] but it's the very same array. However if I do this
int[][] x = {{1,2,3},{1,2,3}};
int[][] y = x.clone();
for(int i = 0; i < y.length; i++) y[i] = y[i].clone();
x[0][0] = 7;
System.out.println(y[0][0]);
Now it prints out 1 since x and y are now independent of each other.
@husoski: My code already solves the problem by calling clone() on every contained array. So there is no need to go through the array again,