摘要: 1.向上转型的一个误区 一直以为Child 继承Parent以后, Parent p = new Child(); p可以调用Child类中拓展Parent的方法,原来必须在强制转换成Child类才可以。代码如下: 从 p[1].h(); 无法使用我感受到了糊涂,如果Child 拓展了Parent 阅读全文
posted @ 2013-09-06 13:45 流水无情88 阅读(229) 评论(0) 推荐(0) 编辑
摘要: 1.向上转型的一个误区一直以为Child 继承Parent以后, Parent p = new Child(); p可以调用Child类中拓展Parent的方法,原来必须在强制转换成Child类才可以。代码如下:class Parent{ public void f(){}; public void g(){};}class Child extends Parent{ public void f(){}; public void g(){}; public void h(){}; public void i(){};}public class ParentS... 阅读全文
posted @ 2013-09-06 13:38 流水无情88 阅读(128) 评论(0) 推荐(0) 编辑