Hi I’m writing the reporting system and want to make end-user specify type if he extends my class.
class A <T extends C>
{...}
class B extends A // Compile error
{...}
class B extends A<D> // Compile error
{...}
class B extends A<C> // Success
Is that possible?
No, for the sake of backwards compatibility, generics in Java are optional. You cannot force the programmer to use them. This will only generate a warning (“do not use raw types”).
If they do use generics, they have to be correct, though. In the case that D does not match the specification, this will be a compiler error.