当前位置: 技术问答>java相关
为什么这样写int[][]={{0},{1,1}};可以,而这样写int[][][]={{0},{1,1},{2,2,2}};不行?
来源: 互联网 发布时间:2015-02-25
本文导语: | public class testDimArray{ public static void main(String[] args){ int[][][] threeDim={{{0},{1}}, {{1},{1}}, {{2},{2,3},{4}}}; System.out.println(threeDim[...
|
public class testDimArray{
public static void main(String[] args){
int[][][] threeDim={{{0},{1}},
{{1},{1}},
{{2},{2,3},{4}}};
System.out.println(threeDim[2][1][1]+"=3");
}
}
the result is
3=3
another way:
int[][] twoDim={new int[2],new int[3],new int[4]};
public static void main(String[] args){
int[][][] threeDim={{{0},{1}},
{{1},{1}},
{{2},{2,3},{4}}};
System.out.println(threeDim[2][1][1]+"=3");
}
}
the result is
3=3
another way:
int[][] twoDim={new int[2],new int[3],new int[4]};
|
try:
int x[][][]={{{0}},{{1,1}},{{2,2,2}}};
int x[][][]={{{0}},{{1,1}},{{2,2,2}}};
|
pls:
int[][]={{0},{1,1},{2,2,2}};
or
int[][][]={{{0},{1}},
{{1},{1}},
{{2},{2,3},{4}}};
use int[0][0][0] to get 0
or
use int[2][1][1] to get 3
int[][]={{0},{1,1},{2,2,2}};
or
int[][][]={{{0},{1}},
{{1},{1}},
{{2},{2,3},{4}}};
use int[0][0][0] to get 0
or
use int[2][1][1] to get 3