第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

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

如何構(gòu)建內(nèi)部類

//外部類HelloWorld

public class HelloWorld {

? ? ? ??

? ? // 內(nèi)部類Inner,類Inner在類HelloWorld的內(nèi)部

? ? public class Inner {

? ? ? ??

// 內(nèi)部類的方法

public void show() {

System.out.println("welcome to imooc!");

}

}

? ? ?

public static void main(String[] args) {

? ? ? ??

? ? ? ? // 創(chuàng)建外部類對象

HelloWorld hello = new HelloWorld();

? ? ? ? // 創(chuàng)建內(nèi)部類對象

Inner i = hello.new Inner();

? ? ? ? // 調(diào)用內(nèi)部類對象的方法

i.show();

}

}


正在回答

1 回答

public class Outer{ //構(gòu)建外部類

????public class Inner{ //構(gòu)建內(nèi)部類

????????public void show(){

????????????????System.out.println( "我是Outer的內(nèi)部類中的方法." ); ??

????????}

? ? ?}

???? public static void main( String[] args ){

????????????Outer one = new Outer(); //創(chuàng)建外部類對象

????????????Inner instan = one.new Inner(); //創(chuàng)建內(nèi)部類對象

????????????instan.show(); //調(diào)用內(nèi)部類對象的方法

????}

}

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消

如何構(gòu)建內(nèi)部類

我要回答 關(guān)注問題
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號