国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(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ó)家法律
鱼台县| 山东省| 英德市| 苗栗县| 宣武区| 毕节市| 临泉县| 新河县| 磴口县| 仙居县| 鹿泉市| 宝丰县| 绥滨县| 渭源县| 和硕县| 漾濞| 青海省| 镇宁| 喀喇| 蒲城县| 进贤县| 河曲县| 灵宝市| 文安县| 涞源县| 牙克石市| 平顺县| 邯郸县| 巴青县| 长海县| 新闻| 博罗县| 凭祥市| 廊坊市| 宁河县| 禄丰县| 伊宁县| 赤水市| 黔西| 兰州市| 曲周县|