Results 1 to 3 of 3
- 04-11-2011, 01:48 AM #1
Member
- Join Date
- Apr 2011
- Posts
- 52
- Rep Power
- 0
- 04-11-2011, 02:07 AM #2
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
Have you tried reading what the two things do and how they differ? Or if they differ? If not, here is a link to where you should be able to find your answer:
Lesson: Generics (The Java™ Tutorials > Bonus)
The ? is a wildcard, and <? extends X> is a bounded wildcard to help you narrow your search. It has something to do with reading and writing.
For example, with the removeAll method, it really doesn't care what the type of the passed in argument is. However, when adding a collection you only want types of E and it's subclasses to be added to the collection. You don't want to allow a collection of type Ham to be added to a collection of Type Hamster, that wouldn't make much sense.
My understanding of generics is admittedly rusty so my explanation may have some flaws. That is where the tutorials will come in handy. Check them out.Last edited by sunde887; 04-11-2011 at 02:14 AM.
- 04-11-2011, 03:00 AM #3
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,537
- Rep Power
- 11
Why not use removeAll(Collection<? extends E> c) ?
I guess the reason is the same the reason why remove() is declared as "boolean remove(Object)" while add() is declared as "boolean add(E)".
There's discussion at stackoverflow.
Similar Threads
-
Question concerning interface functionality
By Morning-owl in forum New To JavaReplies: 3Last Post: 04-04-2011, 08:25 PM -
Interface Question
By superman1938 in forum Advanced JavaReplies: 1Last Post: 12-14-2010, 04:28 AM -
Garbage Collection Question
By DrMath in forum New To JavaReplies: 5Last Post: 10-03-2009, 10:08 AM -
question on listener interface
By Minu in forum Java ServletReplies: 1Last Post: 01-16-2009, 10:33 AM -
Interface question in java
By tony404 in forum Advanced JavaReplies: 2Last Post: 06-27-2008, 11:47 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks