I want to make an exact copy of given array to some other array but such that even though I change the value of any in the new array it does not change the value in the original array. I tried the following code but after the third line both the array changes and attains the same value.
int [][]a = new int[][]{{1,2},{3,4},{5,6}};
int[][] b = a;
b[1][0] = 7;
instead of the second line I also tried
int[][] b = (int[][])a.clone();
int [][] b = new int [3][2];
System.arraycopy(a,0,b,0,a.length);
int [][] b = Arrays.copyOf(a,a.length);
None of these helped. Please suggest me an appropriate method. I've tested this piece of code in eclipse scrapbook.