java用内部类实现多重继承
生活随笔
收集整理的這篇文章主要介紹了
java用内部类实现多重继承
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
最常見的實現(xiàn)多重繼承的方式,是implements interface1,interface2,interface3…
也可以通過多個內(nèi)部類extends多個抽象類。
示例如下
public class Father {public int strong(){return 9;} }public class Mother {public int kind(){return 8;} }public class Son {/*** 內(nèi)部類繼承Father類*/class Father_1 extends Father{public int strong(){return super.strong() + 1;}}class Mother_1 extends Mother{public int kind(){return super.kind() - 2;}}public int getStrong(){return new Father_1().strong();}public int getKind(){return new Mother_1().kind();} } 創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎總結(jié)
以上是生活随笔為你收集整理的java用内部类实现多重继承的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Spring实例化Bean
- 下一篇: css动画与js动画的区别