Alex Rivera | Logout

ArrayList<T> vs ArrayList<?>

Asked 2011-07-21T17:32:52.313
11

I know what ArrayList<T> is used for, but when should I use ArrayList<?> ? can you explain with example? thanks.

Edit
Report

1 Answer

5

http://download.oracle.com/javase/tutorial/java/generics/wildcards.html

Note: It's also possible to specify a lower bound by using the super keyword instead of extends. The code <? super Animal>, therefore, would be read as "an unknown type that is a supertype of Animal, possibly Animal itself". You can also specify an unknown type with an unbounded wildcard, which simply looks like <?>. An unbounded wildcard is essentially the same as saying <? extends Object>.

answered 2011-07-21T17:37:31.330

Your Answer