I'm trying to explain java Polymorphism to my self so I've simply created a project showing that Family is the SuperClass and SubClasses areBrothersSisters`
The thing is when I compile I receive an error saying that
Cannot find the Constructor Sisters
Cannot find the Constructor Brothers
Could someone explain to me?
Thanks guys.
class Family {
private String name,age;
public Family(String name,String age){
this.name = name;
this.age = age;
}
public String toString(){
return "name : " + name + "\tage " + age ;
}
}
class Brothers extends Family{
public Brothers(String name, String age){
super(name,age);
}
}
class Sisters extends Family{
public Sisters(String name, String age){
super(name,age);
}
}
class FamilyTest{
public static void main(String[] args){
Family[] Member= new Family[3];
Member[1] = new Sisters("LALA",22);
Member[2] = new Brothers("Mike",18);
}
}
Brothera kind ofFamiliy? No, it is aFamilyMember. Please use this "... is a kind of ..." test upfront and before declaring classes.