close

p7-20

類別可以實作兩個以上的介面

 

For Example

interface student{

  void study();

  void discuss();

}

 

interface teacher{

  void teach();

  void discuss();

}

 

若是discuss()做的內容都相同,可以設定一個父介面描述這個method

==============  Better Method  ===============

interface Action{

  void discuss();

}


interface student extends Action {

  void study();

}

 

interfeace teacher extends Action {

  void teach();

}

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 Justin258 的頭像
    Justin258

    Justin258的部落格

    Justin258 發表在 痞客邦 留言(0) 人氣()