java 二维数组

54 阅读1分钟
/**
 * java 二维数组
 * type[][] typeName = new type[typeLength1][typeLength2];
 * type 可以为基本数据类型和复合数据类型,typeLength1 和 typeLength2 必须为正整数,typeLength1 为行数,typeLength2 为列数。
 */
public class learn_13_2 {
    public static void main(String[] args) {
        int a[][] = new int[2][3];
        for (int i = 0;i < 2;i++){
            for (int j = 0;j < 3;j++){
                a[i][j] = i + j;
            }
        }
        for (int i = 0;i < 2;i++){
            for (int j = 0;j < 3;j++){
                System.out.println(a[i][j]);
            }
        }
    }
}