如何实现多个接口Implementing Multiple Interface

实现多个接口Implementing Multiple Interface

接 口的优势:马克-to-win:类可以实现多个接口。与之相反,类只能继承一个超类(抽象类或其他类)。 A class can implement multiple interface, but a class can have only one superclass. this is also the difference between abstract class and interface.

例1.4:
interface HandPhone {
    void talk();
}
interface Computer {
    void surfWeb();
}
class SmartPhoneMark_to_win implements HandPhone, Computer {
    public void surfWeb() {
        System.out.println("只要有wifi, 我就能上网");
    }
    public void talk() {
        System.out.println("马克-to-win: 和传统电话一样, 我能通话");
。。。。。。。。。。。。。。。。。
详情请进:http://www.mark-to-win.com/JavaBeginner/JavaBeginner4_web.html#ImplementingMultipleInterface
阅读更多

没有更多推荐了,返回首页