class Animal { public String name; Animal (String name) { this.name = name; }} class Dog extends Animal { public String furColor; Dog(String n,String c) { super(n);c = furColor; }}public class Test { public static void main(String args[]) { Animal a = new Animal("name"); a = new Dog("bigyellow","yellow"); System.out.println(a.name); Dog d1 = (Dog) a; System.out.println(d1.furColor); }}请问为啥这里我写c = furColor; d1.furColor输出结果为null, 写成furColor=d1输出结果就是yellow呢?
添加回答
举报
0/150
提交
取消