感觉强制转换没有意义啊 求解答
比如 父类Animal() 子类 Cat()
Animal a =new Cat()
然后是说 a 不能用子类Cat()中特有的方法 比如 catchMouse()方法 然后介绍强转方法
Cat c = (Cat)a
就是可以用cat中特有的方法 c.catchMouse();
但是感觉完全没有意义啊
跟直接Cat c =new Cat()有什么区别吗
比如 父类Animal() 子类 Cat()
Animal a =new Cat()
然后是说 a 不能用子类Cat()中特有的方法 比如 catchMouse()方法 然后介绍强转方法
Cat c = (Cat)a
就是可以用cat中特有的方法 c.catchMouse();
但是感觉完全没有意义啊
跟直接Cat c =new Cat()有什么区别吗
