zoukankan      html  css  js  c++  java
  • 《Java入门第二季》第五章 阶段练习

    /**
     *         ┏┓   ┏┓
     *        ┏┛┻━━━┛┻┓
     *        ┃       ┃  
     *        ┃   ━   ┃
     *        ┃ >   < ┃
     *        ┃       ┃
     *        ┃... ⌒ ... ┃
     *        ┃       ┃
     *        ┗━┓   ┏━┛
     *          ┃   ┃ Code is far away from bug with the animal protecting          
     *          ┃   ┃ 神兽保佑,代码无bug
     *          ┃   ┃           
     *          ┃   ┃       
     *          ┃   ┃
     *          ┃   ┃           
     *          ┃   ┗━━━┓
     *          ┃       ┣┓
     *          ┃       ┏┛
     *          ┗┓┓┏━┳┓┏┛
     *           ┃┫┫ ┃┫┫
     *           ┗┻┛ ┗┻┛
     */
    public class Test {
        public static void main(String[] args) {
            Person p1 = new Chinese();
            Person p2 = new American();
            p1.say();
            p2.say();
        }
    }
    /* Output:
    你好
    Hello
     */
    public abstract class Person {
        abstract void say();
    }
    public class Chinese extends Person {
        public void say() {
            System.out.println("你好");
        }
    }
    public class American extends Person {
        public void say() {
            System.out.println("Hello");
        }
    }

     也可以实现一个Sayable接口。

  • 相关阅读:
    SqlHelper.cs源代码,学习!
    Fiddler工具介绍一
    dhl:Linq之group by 学习 使用
    vpc2007上安装windows7
    (五) ViewEngine 深入解析与应用实例
    VirtualPC2007添加Shared Folder的方法for dos
    SQL Server 2005 无法连接数据库终极解决方案!
    switch……case里的case 同时定义多个值
    dhl:AjaxPro的使用后感
    ifram高度自适应,获取iframe元素,控制父页面
  • 原文地址:https://www.cnblogs.com/xkxf/p/6536666.html
Copyright © 2011-2022 走看看