So, I have a set up like below where A
and B
are both abstract
classes.
abstract class ObjectA extends ObjectB<ObjectC> {
}
public class ObjectD extends ObjectA{
public static void main(String[] args){
ObjectA x = new ObjectD();
ObjectD y = (ObjectD)x; // down cast
}
}
I'm using a library where I want to avail of the abstract methods in ObjectB
and provide a default constructor for all classes - ObjectA
. I'm not sure on my approach. BTW ObjectB
is part of a predefine library I'm using. ObjectA
is my own class providing default properties and constructor.
I'm not so sure on my approach, doesn't seem nice?
Just to add:
ObjectA requires a type that extends ObjectA.
public abstract class ObjectA<T extends ObjectA<T>> {
}
Hence, the need for what I'm doing.