为什么System.out.println()放到注释的地方就出错,放到内部类外面就可以执行?
public class Muk2_8{
private String name = "我爱";
public void show(){
class Minner{
int score = 90;
public int getScore(){
return score + 10;
}
//System.out.println("姓名:"+name);
//System.out.println("加分后成绩:"+newScore);
}
Minner hello = new Minner();
int newScore = hello.getScore();
System.out.println("姓名:"+name);
System.out.println("加分后成绩:"+newScore);
}
public static void main(String[] args){
Muk2_8 wi = new Muk2_8();
wi.show();
}
}