这可能是一个太愚蠢的问题,但我无法弄明白。使用这个atm
private static String[][][] ns=new String[][][]{{{"52","14",""},{"90","34",""},{"","",""}},{{"89","",""},{"67","78",""},{"","",""}},...
其余元素是{“”,“”,“”} ..所以数组ns必须是ns [10] [3] [3]。我怎样才能定义这个而不是写所有{“”,“”,“”} ......?
答案 0 :(得分:0)
请勿通过new T[] {}
初始化您的数组。
String[][][] ns = new String[10][3][3];
for (int i = 0; i < ns.length; i++) {
for (int j = 0; j < ns[i].length; j++) {
for (int k = 0; k < ns[i][j].length; k++) {
ns[i][j][k] = "";
}
}
}
ns[0][0][0] = "52";
ns[0][0][1] = "14";
ns[0][1][0] = "90";
ns[0][1][1] = "34";
ns[0][3][0] = "89";
ns[0][4][0] = "67";
ns[0][4][1] = "78";