類名.變量名怎么不能輸出
public class HelloWorld {
?? ?
??? // 定義靜態(tài)變量,保存班級名稱
?? ??? public? String className = "JAVA開發(fā)一班";
?? ?public static void main(String[] args) {
?????? ?
?? ??? ?// 訪問靜態(tài)變量,輸出班級名稱
?? ??? ?System.out.println(HelloWorld.className);
?? ?}
}
2016-03-24
Cannot make a static reference to the non-static field className