When using Java Arrays.fill(array,int[] subArray), why subArray share the same memory block?

后端 未结 0 1272
一生所求
一生所求 2020-12-12 18:42
int[][] dp = new int[5][2];
Arrays.fill(dp,new int[2]{2,3});
dp[1][0] = 10;

I thought that only dp[1][0] is changed to 10, but all dp[x][0] are 10(x

相关标签:
回答
  • 消灭零回复
提交回复
热议问题