Wednesday, August 01, 2007

Java Generic Question

Being a C++ programmer, I naturally gravitated quickly toward Java 1.5 for generics. I've never been very good at remembering exact syntax and potential compiler errors so maybe I'm missing something, but given this scenario:

interface A

class B implements A
class C implements A

interface D

class E implements D

Now, why can't I cast E< B > or E< C > to D< A >? Is there a massive bug hiding in that cast that I'm not noticing, or does the compiler jut not want to figure out that it's legal? Or, have I missed some sort of special casting method in Java?

Labels: ,

0 Comments:

Post a Comment

<< Home