求解謝謝了
package com.mxdximmco; class Shape { System.out.println("訪問外部類中的score:" + ?HelloWorld.score ? ? ? ? ?); } 為什么他System的一直報錯
package com.mxdximmco; class Shape { System.out.println("訪問外部類中的score:" + ?HelloWorld.score ? ? ? ? ?); } 為什么他System的一直報錯
2016-10-02
舉報
2016-10-02
public class Shape {
int score =10;
? ? public static void main(String[] args) {
? ? ? ? Shape a=new Shape();
? ? ? ?System.out.println("訪問外部類中的score:" + a.score);?
? ? }?
}
//我這樣就沒出錯
2016-10-02
你檢查一下main函數里面有沒有創建一個helloworld對象,沒有創建對象是不能輸出非靜態變量的
2016-10-02
你把你全部代碼帖一下一起研究一下
2016-10-02
個人見解:你需要把print函數放在main函數里面執行。。。