而且,我照书上得方法 int[][] towDim; twoDim[0] = new int[2]; twoDim[1] = new int[4]; twoDim[2] = new int[6]; twoDim[3] = new int[8]; 这样编译夜通不过啊
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
你编译试试看啊 class SL275 { public static void main(String[] args) { int towDim[][]; twoDim[0] = new int[2]; twoDim[1] = new int[4]; twoDim[2] = new int[6]; twoDim[3] = new int[8]; } }
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=3another way: int[][] twoDim={new int[2],new int[3],new int[4]};
既然这个int[][] twoDim={new int[2],new int[3],new int[4]};可以 哪为什么 int towDim[][]; twoDim[0] = new int[2]; twoDim[1] = new int[4]; twoDim[2] = new int[6]; twoDim[3] = new int[8]; 不行?
int[][] towDim;
twoDim[0] = new int[2];
twoDim[1] = new int[4];
twoDim[2] = new int[6];
twoDim[3] = new int[8];
这样编译夜通不过啊
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
class SL275
{
public static void main(String[] args)
{ int towDim[][];
twoDim[0] = new int[2];
twoDim[1] = new int[4];
twoDim[2] = new int[6];
twoDim[3] = new int[8]; }
}
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=3another way:
int[][] twoDim={new int[2],new int[3],new int[4]};
哪为什么
int towDim[][];
twoDim[0] = new int[2];
twoDim[1] = new int[4];
twoDim[2] = new int[6];
twoDim[3] = new int[8];
不行?