你們這個都能運行嗎????為什么我的不行
public class HelloWorld {
? ??
? ? private String name = "愛慕課";
? ??
? ? // 外部類中的show方法
? ? public void show() {?
// 定義方法內(nèi)部類
class MInner {
int score = 83;
public int getScore() {
return score + 10;
}
}
? ? ? ??
// 創(chuàng)建方法內(nèi)部類的對象
? ? MInner mi=new MInner();
? ? ?
? ? ? ??
? ? ? ? // 調用內(nèi)部類的方法
? ? ? ?int newScore=mi.getScore();
System.out.println("姓名:" + name + "\n加分后的成績:" +newScore);
}
? ??
// 測試方法內(nèi)部類
public static void main(String[] args) {
? ? ? ??
// 創(chuàng)建外部類的對象
? ? ? ? HelloWorld.mo=new HelloWorld();
? ? ? ??
? ? ? ? // 調用外部類的方法
mo.show();
}
}
2018-08-20
創(chuàng)建外部類的對象HelloWorld mo沒有.
2018-08-17
哦哦? 我知道了?手誤了