五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

component組合的用法

2022-06-15 20:38 作者:虛云幻仙  | 我要投稿

/**
* 測(cè)試組合component
*/

public class TestComponent {
}
class Information {
? ?String name;
? ?int age;
}

class Account{
? ?int id;
? ?public void aaa(){
? ? ? ?System.out.println("a");
? ?}
}

class S1{
? ?Information in =new Information();
? ?//組合component 在s1類里new一個(gè)information類 通過(guò)s1類對(duì)象名.in使用information類的內(nèi)容
? ?Account ac = new Account();
? ?//可以組合多個(gè)類
? ?public void print(String name,int age,int id){
? ? ? ?this.in.name = name;
? ? ? ?//this代表調(diào)用方法的對(duì)象 對(duì)象的information對(duì)象的name屬性
? ? ? ?this.in.age = age;
? ? ? ?this.ac.id = id;
? ? ? ?//對(duì)象的account對(duì)象的id屬性
? ? ? ?System.out.println(this.in.name);
? ? ? ?System.out.println(this.in.age);
? ? ? ?System.out.println(this.ac.id);
? ?}
? ?//in和ac作為s1的組成部分 不同于繼承extends的延伸、拓展
? ?public void aaa(){
? ? ? ?System.out.println("aa");
? ?}
? ?//s1類對(duì)象名.aaa() 和 .ac.aaa() 不沖突
}


component組合的用法的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
池州市| 垣曲县| 天柱县| 互助| 西充县| 都兰县| 鄂州市| 平昌县| 瑞丽市| 丰顺县| 三河市| 罗山县| 岑溪市| 格尔木市| 道真| 裕民县| 金门县| 广饶县| 阳信县| 台湾省| 定兴县| 榆中县| 九龙城区| 南开区| 乳源| 涿州市| 依兰县| 卢湾区| 湖南省| 西城区| 广平县| 神木县| 大渡口区| 托克逊县| 吐鲁番市| 高要市| 页游| 泾源县| 喜德县| 成安县| 青阳县|