二维数组
定义:二维数组是指以一维数组作为元素的数组。
语法:数据类型[行][列] 数组名。
二维数组的初始化
静态初始化
动态初始化
实现代码
public class Test7 {
public static void main(String[] args) {
int[][] scores = {
{92,85},
{91,65},
{90,33}
};
for(int i = 0;i<scores.length;i++){
for(int j = 0;j<scores.length-1;j++){
System.out.println(scores[i][j]);
}
}
for(int i = 0;i<scores.length;i++){
for(int j = 0;j<scores.length-1;j++){
if(j==0) {
scores[i][j] = j+1;
System.out.println(scores[i][j]);
}
if(j==1){
scores[i][j] = j+1;
System.out.println(scores[i][j]);
}
}
}
}
}
实现结果