是我想要做的是這樣的:是否可以聲明String [] []類型的全局數組?
class test{
public static String[][] p;
}
但什麼是錯的。 當我嘗試通過寫某物它:
p[][]={...};
它說:「P不能被解析爲一個類型」。
編輯: 好吧,我看到有一些問題與理解我在說什麼,所以我在這裏發佈代碼。
public class Test{
static String[][] plansza;
public static void main(String []arg){
p[][]={ {" ","A", "B", "C", "D", "E", "F", "G", "H"},
{"1.","0","1","0","1","0","1","0","1"},
{"2.","1","0","1","0","1","0","1","0"},
{"3.","0","1","0","1","0","1","0","1"},
{"4.","0","0","0","0","0","0","0","0"},
{"5.","0","0","0","0","0","0","0","0"},
{"6.","2","0","2","0","2","0","2","0"},
{"7.","0","2","0","2","0","2","0","2"},
{"8.","2","0","2","0","2","0","2","0"}
};
}
這不是你如何「寫的東西吧。」參考[基礎教程](http://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html)。 – Maroun
也許試試'p = new String [] [] {{...},{...}};'' – Pshemo