我想整型的二维数组复制到另一个,这样,原来当复制的数组被修改修改Java中的复制二维数组
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);
但是不受影响,原来被在此处修改
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
我试过的clone(),仍然是行为是相同的
这是为什么?任何想法如何保持原来的未修改?
已经回答的问题 - http://stackoverflow.com/questions/6101684/system-arraycopy-question – Joe2013 2013-03-11 08:40:46
已经回答了。 http://stackoverflow.com/questions/6101684/system-arraycopy-question – Joe2013 2013-03-11 08:42:13