最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(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ó)家法律
萝北县| 呼伦贝尔市| 钟祥市| 广平县| 江城| 新丰县| 师宗县| 罗田县| 温泉县| 吉首市| 改则县| 怀集县| 松桃| 曲阳县| 通河县| 长宁区| 朝阳区| 霸州市| 海阳市| 枣阳市| 北票市| 喀什市| 东城区| 惠东县| 奉新县| 富平县| 新宁县| 安新县| 五河县| 新晃| 封丘县| 射阳县| 城固县| 泸定县| 溧阳市| 梓潼县| 天水市| 饶平县| 青岛市| 青浦区| 泽普县|