package com.mxdximmco; class Shape { System.out.println("访问外部类中的score:" + HelloWorld.score ); } 为什么他System的一直报错
public class Shape {
int score =10;
public static void main(String[] args) {
Shape a=new Shape();
System.out.println("访问外部类中的score:" + a.score);
}
}
//我这样就没出错
你检查一下main函数里面有没有创建一个helloworld对象,没有创建对象是不能输出非静态变量的
你把你全部代码帖一下一起研究一下
个人见解:你需要把print函数放在main函数里面执行。。。