标签:ble 入门 ... test xtend 接口 hello nbsp cti
/** * ┏┓ ┏┓ * ┏┛┻━━━┛┻┓ * ┃ ┃ * ┃ ━ ┃ * ┃ > < ┃ * ┃ ┃ * ┃... ⌒ ... ┃ * ┃ ┃ * ┗━┓ ┏━┛ * ┃ ┃ 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接口。
标签:ble 入门 ... test xtend 接口 hello nbsp cti
原文地址:http://www.cnblogs.com/xkxf/p/6536666.html