以下哪项在 Java 中更快?有没有比这些方法更快的方法?
int[][] matrix = new int[50][50];
for (int k=0;k<10;k++){
// some calculations here before resetting the array to zero
for (int i = 0; i <50; i++) {
for (int j = 0; j <50; j++) {
matrix[i][j]=0;
}
}
}
或这个:
int[][] matrix = new int[50][50];
for (int k=0;k<10;k++){
// some calculations here before resetting the array to zero
matrix = new int[50][50];
}