While I was working on some Java code, I figured that there might be something different between these 2 codes.
I know that they have the same functionality, but I think there is something different between them under the hood.
This is the first code:
int[][] MainMatrix = new int[2][2];
int[][] A = new int[2][2];
MainMatrix[0][0]=100;
MainMatrix[0][1]=200;
MainMatrix[1][0]=300;
MainMatrix[1][1]=400;
A=MainMatrix;
And this is the second one:
int[][] MainMatrix = new int[2][2];
int[][] A = new int[2][2];
MainMatrix[0][0]=100;
MainMatrix[0][1]=200;
MainMatrix[1][0]=300;
MainMatrix[1][1]=400;
for(int i=0;i<2;i++){
for(int j=0;j<2;j++){
A[i][j]=MainMatrix[i][j];
}
}
So, what's the difference?