I just stumbled upon Future<?>
. What is the '?'
Asked
Active
Viewed 570 times
-3

Luiggi Mendoza
- 85,076
- 16
- 154
- 332

Karan
- 14,824
- 24
- 91
- 157
-
3It means it can return a `Future
`. – Luiggi Mendoza May 27 '13 at 14:18 -
http://docs.oracle.com/javase/tutorial/java/generics/capture.html – Brian Roach May 27 '13 at 14:19
-
@LuiggiMendoza Not exactly "instance"---"any reference type" is more appropriate. – Marko Topolnik May 27 '13 at 14:22
-
1@MarkoTopolnik true, comment fixed. – Luiggi Mendoza May 27 '13 at 14:22
-
1I don't think it's fixed :) You still imply a "reference" to name the placeholder for a *type*. There are no instances, nor references to them, involved. – Marko Topolnik May 27 '13 at 14:24
2 Answers
5
It is a wildcard expression used for generics.
See e.g.
http://docs.oracle.com/javase/tutorial/java/generics/capture.html
and
1
Future<?>
is an unbounded wildcard reference and is short for Future<? extends Object>
. Meaning the generic can be of any type.
You could also have Future<? extends T>
, where it has to extend a specific type T (upper bound), or Future<? super T>
where is must be an ancestor of a specific type T (lower bound).
http://docs.oracle.com/javase/tutorial/java/generics/wildcards.html

Ørjan Johansen
- 415
- 3
- 9