Author
? extends String
Rodolfo Mendoza
Greenhorn
Joined: Feb 27, 2008
Posts: 14
posted Mar 05, 2008 16:26:00
Hi guys, Anyone knows why the following code don't work : The following work fine: Thanks,
Uttara Rishi
Ranch Hand
Joined: Feb 24, 2008
Posts: 49
posted Mar 05, 2008 16:50:00
You cannot add anything to a List that uses <? extends> or <?> You can add only when the method signature is <? super Dog? In short <? extends> - no adding. <?> - you can pass anytype into the method but still no adding. <? super> - adding allowed. Hope that helps. Please correct me if I am wrong. Uttara Rishi.
Rodolfo Mendoza
Greenhorn
Joined: Feb 27, 2008
Posts: 14
posted Mar 05, 2008 16:56:00
Uttara thanks You are right...
ahmed yehia
Ranch Hand
Joined: Apr 22, 2006
Posts: 424
posted Mar 05, 2008 17:34:00
You cannot add anything to a List that uses <? extends> or <?>
Thats correct but with little exception that you can add 'null'.
Uttara Rishi
Ranch Hand
Joined: Feb 24, 2008
Posts: 49
posted Mar 05, 2008 18:04:00
Thanks Ahmed.
subject: ? extends String