摘要: 1 [code=java] 2 //多态的经典例子 3 //向上转型后,父类只能调用子类和父类的共同方法和的重写方法(方法名相同,参数也相同),不能调用重载方法(方法名相同,但参数不同) 4 class A { 5 public String show(D obj) { 6 return ("A and D"); 7 } 8 public ... 阅读全文
posted @ 2016-09-12 21:35 从零开始的程序员生活 阅读(223) 评论(0) 推荐(0) 编辑
摘要: 1 public class GenericsDemo06 { 2 3 public static void main(String[] args) { 4 5 Box name = new Box("corn"); 6 Box age = new Box(712); 7 Box number = new... 阅读全文
posted @ 2016-09-12 21:34 从零开始的程序员生活 阅读(166) 评论(0) 推荐(0) 编辑