I am trying to create a set up where a set of subclasses override a superclass. This superclass contains an abstract method - the return type of which would ideally be that of t
How about this:
public abstract class SuperClass> {
public abstract T getSelf();
}
public class SubClass extends SuperClass {
public SubClass getSelf() {
return this;
}
}
I know it's quite repetitive and nothing bounds the type to be the same SubClass
instance, because also AnotherSubClass
would satisfy the bound, but at least it should do the trick.