如何实现多个接口Implementing Multiple Interface

4.实现多个接口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: 和传统电话一样, 我能通话");
    }
}
public class Test {
    public static void main(String args[]) {
        SmartPhoneMark_to_win sp = new SmartPhoneMark_to_win();
。。。。。。。。。。。。。。。。。
详情请进:http://www.mark-to-win.com/index.html?content=JavaBeginner/javaUrl.html&chapter=JavaBeginner/JavaBeginner4_web.html#ImplementingMultipleInterface

猜你喜欢

转载自www.cnblogs.com/mark-to-win/p/9693668.html
今日推荐