亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

靜態內部類通過new外部類().成員的方式訪問外部類的非靜態成員是怎么訪問的,

請給個代碼解釋一下謝謝



正在回答

2 回答

new外部類().成員

其實對應代碼中?

Inner inner=new Inner();

inner.ln();是嗎?


0 回復 有任何疑惑可以回復我~

public class Outer(){

? ? ? ? int score=83;

? ? ? ?public static int Inner(){

? ? ? ? ? ? ? ?public static int In(){

? ? ? ? ? ? ? ? ? ? ? ?int score=93;

? ? ? ? ? ? ? ? ? ? ? ?System.out.println("外部類的score為:"+new Outer().score)

? ? ? ? ? ? ? }

? ? ? ? ? ? ?

? ? ? ?}

}

public static int main(String[]args){

? ? ? ?Inner inner=new Inner();

? ? ? inner.In();

? ? ??

}

這樣運行代碼就能輸出該外部類的非靜態成員了

0 回復 有任何疑惑可以回復我~
#1

淮陰工學院計算機1161劉濤

內部類不要class的嗎?
2018-07-18 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

靜態內部類通過new外部類().成員的方式訪問外部類的非靜態成員是怎么訪問的,

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號