Java Polymorphism code "Cannot find Constructor` -


i'm trying explain java polymorphism self i've created project showing family superclass , subclasses arebrotherssisters`

the thing when compile receive error saying cannot find constructor sisters cannot find constructor brothers

could explain 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);  }  } 

you have age definded string pass integer it.

member[1] = new sisters("lala", "22"); member[2] = new brothers("mike", "18"); 

should work advice change age string int.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -