T
timasmith
So I have (skipping some detail) the following:
public abstract class BaseObject implements IObject {
public abstract void setMethod();
}
public class ChildObject extends BaseObject implements IObject {
public void setMethod() {
// Child implementation
}
}
public class GrandChildObject extends ChildObject {
@override
public void setMethod() {
// grand Child implementation
}
}
then when I am in a method
public void testThis(Object o) {
((IObject) o).setMethod();
}
it executes the ChildObjects implementation
so I tried this
public void testThis(Class GrandChildClass, Object o) {
IBaseObject myObject = (IBaseObject) GrandChildClass.cast(o);
myObject.setMethod();
}
but it still executes the Child method!
How can I execute the GrandChild method from testThis without directly
casting it to a grand child?
thanks
Tim
public abstract class BaseObject implements IObject {
public abstract void setMethod();
}
public class ChildObject extends BaseObject implements IObject {
public void setMethod() {
// Child implementation
}
}
public class GrandChildObject extends ChildObject {
@override
public void setMethod() {
// grand Child implementation
}
}
then when I am in a method
public void testThis(Object o) {
((IObject) o).setMethod();
}
it executes the ChildObjects implementation
so I tried this
public void testThis(Class GrandChildClass, Object o) {
IBaseObject myObject = (IBaseObject) GrandChildClass.cast(o);
myObject.setMethod();
}
but it still executes the Child method!
How can I execute the GrandChild method from testThis without directly
casting it to a grand child?
thanks
Tim