I'm facing problem while trying to implement the following code.
While trying this i am getting the error as mentioned above. Error 1 and 2. Please let me know exactly why, this error is coming. Conceptually where am I wrong? [ June 10, 2007: Message edited by: babai bhaumik ]
void showTwo(W<? extends Two> o2) // quote: My under standing -Now I can pass objects of type Two or anything which extends Two, here it is Three and Four
No, the showTwo()-method takes references of untyped class W or typed references of W<Two>, W<Three> or W<Four> and not of Type Two. Would you ever try to pass this method:
void method(List<Integer> list)
an Integer-object? [ June 10, 2007: Message edited by: Sasha Ruehmkorf ]
The reason is - method void showTwo(W<? extends Two> o2) expects a W object of type Two or Three (or, as Sasha said, without type, e.g. a raw type). - method void showThree(W<? extends Three> o2) expects a W object of type Three (or, again, raw type).