二維數組:(實際上是一個一維數組,它的每個元素又是一個一維數組),數組
能夠看作是一張表格。spa
初始化:code
動態初始化blog
int[ ][ ] arr = new int[3][2];class
定義了一個二維數組,其中有3個一維數組,每個一維數組中有2個元素二維數組
靜態初始化static
int[ ][ ] arr = new int[][]{{1,2},{3,4},{5,6}};di
int[ ][ ] arr = {{1,2},{3,4},{5,6}};co
Eg:new
public class Demo3 { public static void main(String[] args) { int age[][] = new int[][]{{1,2},{3,4},{5,6,7}}; System.out.println(age[0].length);//2 System.out.println(age[2].length);//3 } }