能不能幫我看看代碼有沒有什么問題
public?class?HelloWorld?{ ???? ????//?定義靜態(tài)變量,保存班級(jí)名稱 ???????????String?className?=?"JAVA開發(fā)一班"; public?static?void?main(String[]?args)?{ ???????? //?訪問靜態(tài)變量,輸出班級(jí)名稱 HelloWorld?s=?new?HelloWorld(); ????????????????System.out.println(s.className); } }
2016-05-16
要使用靜態(tài)變量、這里都沒定義、
public class HelloWorld {
?? ?
??? // 定義靜態(tài)變量,保存班級(jí)名稱
?? ???? static? String className = "JAVA開發(fā)一班";
?? ?public static void main(String[] args) {
?????? ?
?? ??? ?// 訪問靜態(tài)變量,輸出班級(jí)名稱
?? ??? ?System.out.println(HelloWorld.className);
?? ?}
}
2016-04-16
代碼沒有問題,不過人家不是讓你用靜態(tài)變量嗎