I have a superclass Person, which contains the following method:
public String getClasHierarchy()
{
return "Person";
} //getClassHierarchy
I cannot change this class.
I also have 10 subclasses of person, which i need to add a similar method to in order to return a string consisting of the name of the class, followed by a “>” then followed by the string returned by getClassHierarchy() from the superclass. I can’t rely on knowing what the class hierarchy above them is. Somehow, i need to invoke the method from the superclass. Anyone have any ideas?
Thanks a lot
You are looking for the ‘super’ keyword
Anyway, this is best done by reflection rather than reinventing the wheel.