求解謝謝了
package com.mxdximmco; class Shape { System.out.println("訪問外部類中的score:" + ?HelloWorld.score ? ? ? ? ?); } 為什么他System的一直報(bào)錯
package com.mxdximmco; class Shape { System.out.println("訪問外部類中的score:" + ?HelloWorld.score ? ? ? ? ?); } 為什么他System的一直報(bào)錯
2016-10-02
舉報(bào)
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函數(shù)里面有沒有創(chuàng)建一個helloworld對象,沒有創(chuàng)建對象是不能輸出非靜態(tài)變量的
2016-10-02
你把你全部代碼帖一下一起研究一下
2016-10-02
個人見解:你需要把print函數(shù)放在main函數(shù)里面執(zhí)行。。。