-3

I just stumbled upon Future<?>. What is the '?'

http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/AbstractExecutorService.html#submit(java.lang.Runnable)

Luiggi Mendoza
  • 85,076
  • 16
  • 154
  • 332
Karan
  • 14,824
  • 24
  • 91
  • 157

2 Answers2

5

It is a wildcard expression used for generics.

See e.g.

http://docs.oracle.com/javase/tutorial/java/generics/capture.html

and

Difference between generic type and wildcard type

Community
  • 1
  • 1
davek
  • 22,499
  • 9
  • 75
  • 95
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