五月天青色头像情侣网名,国产亚洲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ó)家法律
资溪县| 从化市| 筠连县| 平安县| 滦平县| 深州市| 包头市| 康平县| 宁武县| 秦皇岛市| 雅安市| 凭祥市| 陈巴尔虎旗| 依兰县| 巨鹿县| 龙岩市| 桑植县| 永济市| 浦北县| 宜丰县| 兴业县| 台州市| 呼玛县| 阜宁县| 合川市| 洮南市| 呼图壁县| 青阳县| 肃北| 呼和浩特市| 玉溪市| 元朗区| 外汇| 博客| 定结县| 博罗县| 镇江市| 九江市| 商河县| 轮台县| 成武县|