package com.test; public class Test { public static void main(String[] args) { // TODO Auto-generated method stub //两种二位数组定义方式 // int a[][] = new int[2][3]; // int[][] b = new int[2][3]; //两种初始化方式 /*//1 定义的同时初始化 int[][] arry = {{0, 0, 0, 0, 0, 0}, {0, 0, 1, 0, 0, 0}, {0, 2, 0, 3, 0, 0}, {0, 0, 0, 0, 0, 0}};*/ //该初始化方式会报错 // int[][] array = new int[4][6]; // array[4][6] = {{0, 0, 0, 0, 0, 0},{0, 0, 1, 0, 0, 0}, {0, 2, 0, 3, 0, 0},{0, 0, 0, 0, 0, 0}}; //该初始化方式会报错 // int[] arra = new int[2]; // arra = {1, 2}; //应改为 // int[] arra2 = {1, 2}; //2 首先开辟数组空间,再逐个初始化 int[][] array = new int[4][6]; array[1][2] = 1; array[2][1] = 2; array[2][3] = 3; //把图形输出 //先访问行 for (int i = 0; i < array.length; i++) { //后打印列 for (int j = 0; j < 6; j++) { System.out.print(array[i][j]+" "); } //换行 System.out.println(); } } }