I am trying to copy a 2d array of ints to another,such that the original remains unaffected when copied array is modified
int[][] t3 = new int[][]{ {1,2,3}, {0,4,6}, {7,8,9} }; show(t3); int[][] t4 = new int[t3.length][t3[0].length]; System.arraycopy(t3, 0,t4 ,0, t3.length-1); show(t4); t3[0][0]=99; show(t3); show(t4); However,the original gets modified here
t3 1 2 3 0 4 6 7 8 9 t4 1 2 3 0 4 6 0 0 0 t3 modified 99 2 3 0 4 6 7 8 9 t4 99 2 3 0 4 6 0 0 0 I tried clone() ,still the behaviour is the same
Why is this? Any idea how to keep the original unmodified?