(java) generic class to derive from its generic type parameter?

So, I want a generic class to derive from its generic type parameter You just can't do that, I'm afraid. There are various technical reasons for this, not least of which is type erasure You should look for an alternative solution to your issues - this idea is a dead end.

So, I want a generic class to derive from its generic type parameter. You just can't do that, I'm afraid. There are various technical reasons for this, not least of which is type erasure.

You should look for an alternative solution to your issues - this idea is a dead end.

As a curious sidenote: is this possible in . NET/C#? It doesn't use erasure, but I guess it still won't work there either.

– Joachim Sauer Jul 20 at 11:26 Dead end uh... blah.... and thanks Jon. – Poni Jul 20 at 11:51 @Joachim: Nope, . NET doesn't allow it either.

– Jon Skeet Jul 20 at 12:07 Thanks Jon! @#$%^ – Poni Jul 20 at 21:38.

Nope, your goal is near a Dynamic type, which java does not support.

Maybe. The first example works while the second doesn't. They should allow it.

And no, it's not dynamic actually, as it compiles before runtime. – Poni Jul 20 at 12:16 If you don't know Who is, how could you extend it? The compiler would go nuts.

Could have abstract methods, or even be a final class. – Everton Agner Jul 21 at 17:30.

Related Questions