- All Superinterfaces:
Callable<T>
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Interface for executing code that returns a value.
A CallableReturns object can be constructed inside an object's methods
so that otherwise hidden fields and methods are
accessible. For example
Map<String, CallableReturns<Integer>> table = ...;
void foo(final int i) {
CallableReturns<Integer> callable
= new CallableReturns<Integer>() {
public Integer call() {
return Integer.valueOf(i);
}
};
table.put("foo", callable);
}
void bar() {
System.out.println(table.get("foo").call());
}
Note: this class was written independently of the class
Callable
and was subsequently
modified to extend Callable
for
interoperability reasons. It is not being deprecated because
the naming convention fits a pattern used in this package.-
Method Summary