Given these classes:
class Father {
public Father getMe() {
return this;
}
}
class Child extends Father { .. }
I'm calling the public method of the Father class from the Child class:
Child c = new Child();
Child c1 = c.getMe();
So, this is not working, i have to use a cast to make it work :
Child c1 = (Child) c.getMe();
The question is: is there a better way to make it work without the cast? can be like this ?? :
public <T extends Father> T getMe() {
return this;
}
Thanks in advance.