We can get away with this in .NET:
interface I<A> {}
interface I<A, B> {}
... but in Java, the same code will result in a compilation error.
That's interesting, given that even if the type information is gone at runtime, one would expect the information about the number of type parameter to still be there.
If this limitation is related to type erasure, can someone explain why?
It's not related to type erasure so much as to the ambiguity that would arise from using the raw type:
I eye = null; // which 'I' is it?
Raw types are allowed in order to accommodate code written before generics were introduced in JDK 5.0.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With