Tuesday, August 27, 2013

Java - problems with inheritance

Java - problems with inheritance

I have this two classes:
public class Superclass
{
public Superclass();
...
}
and
public class ChildClass extends Superclass
{
public ChildClass();
public setname(String name)
{
...
}
}
if I do this:
Superclass a;
a = new ChildClass();
a.setname("Roger");
i get this warning: The method setname(String) is undefined for the type
Superclass. How to resolve? Thanks

No comments:

Post a Comment