What does List<?>
mean, does it mean simply a list of objects of unspecified type?
Googling for the string <?>
returns nothing useful (:
What does List<?>
mean, does it mean simply a list of objects of unspecified type?
Googling for the string <?>
returns nothing useful (:
? is nothing but Wildcard in Generics
There are 3 different kind of Wildcards in Generics
1) Upper Bounded Wildcards: Uses extends key word
2) Lower Bounded Wildcards
3) Unbounded Wildcard
You are probably looking at the template based
List
class. You can create a list of strings byList<String> myList = new MyList<String>();
as an example. Check the documentation for all the types it supports. It should support any object type, but if there is a sort functionality you have to supply some compare functions.Note that in the example above
MyList
is a concrete class that implements theList
interface in Java. It can beArrayList
.EDIT: I assumed
List
as a concrete class by mistake. Fixed the error above. Thanks Jon.Sounds like you should look for some documentation on Java generics.
The
List<?>
means that it is an object based on a currently unspecified type. That specification is made when the class is instantiated.For example:
is a list of String objects.