数据类型[][] 数组名 = new 数据类型[数组的长度][数组的长度];
public static void main ( String [] args ) {????????//定义了一个长度为 10 的二维数组,每一个空间中只能存放长度为 3 的字符串数组????????String [][] personInfos = new String [ 10 ][ 3 ];????????//定义了一个长度为 5 的二维数组,每一个空间中只能存放长度为 2 的 double 数组????????double [][] agesAndScores = new double [ 5 ][ 2 ];????????agesAndScores [ 0 ] = new double []{ 18 , 60 };????????agesAndScores [ 1 ] = new double []{ 19 , 65 };????????agesAndScores [ 2 ] = new double []{ 28 , 90 };????????agesAndScores [ 3 ] = new double []{ 22 , 55 };????????agesAndScores [ 4 ] = new double []{ 21 , 60 };????????//定义了一个长度为 5 的二维数组,每一个空间中可以存放任意长度的字符串数组????????String [][] infos = new String [ 5 ][];????????infos [ 0 ] = new String []{ " 刘德华 " };????????infos [ 1 ] = new String []{ " 张学友 " , " 很牛逼 " };????????infos [ 2 ] = new String []{ " 张三 " , " 学渣 " , " 整天不务正业 " , " 吃喝嫖赌样样会 " };}
public static void main ( String [] args ) {????????String [][] musicInfos = new String [ 5 ][ 3 ];????????Scanner sc = new Scanner ( System . in );????????for ( int i = 0 ; i < musicInfos . length ; i ++ ){????????????????System . out . println ( " 请输入歌曲名称: " );????????????????String name = sc . next ();????????????????System . out . println ( " 请输入歌曲歌手: " );????????????????String singer = sc . next ();????????????????System . out . println ( " 请输入歌曲出版年月: " );????????????????String date = sc . next ();????????????????musicInfos [ i ] = new String []{ name , singer , date };????????}}