package testCasting;
public class Animal {
String eyes;
int age;
public Animal(){
}
}
class Dog extends Animal {
String furcolor;
public Dog(String eyes,int age,String furcolor){
super();
this.eyes=eyes;
this.age=age;
this.furcolor=furcolor;
}
public String toString(){
return this.eyes+this.age+this.furcolor;
}
}
class Cat extends Animal{
String weight;
public Cat(String eyes,int age,String weight){
super();
this.eyes=eyes;
this.age=age;
this.weight=weight;
}
public String toString(){
return this.eyes+this.age+this.weight;
}
}
网络视频说super()出现是因为要构建子类的一个对象,必须要先用super()构造一个父类的对象,而我们老师说,super()只是进行初始化的。那么super();在这里究竟起到了一个什么作用呢?
幕布斯6054654
摇曳的蔷薇
DIEA
相关分类