不規(guī)則二維數(shù)組public
class
Array{
public
static
void
main(String [] args){
int
[][] a =
new
int
[][]{{
1
,
2
,
3
},{
4
},{
5
,
6
,
7
,
8
}};
//定義一個不規(guī)整的二維數(shù)組
for
(
int
i =
0
;i<a.length;i++){
//遍歷行數(shù)
for
(
int
j=
0
;j<a[i].length;j++){
//遍歷列數(shù)
System.out.print(a[i][j]);
}
System.out.println();
}
}
} |
|