Standard interface for a function with no arguments
1 answer
This a Supplier<T>
- accepts nothing and supplies T
. And the method abstract
it defines is nice to callget()
interface Supplier<T> {
T get();
}
Note that in Java8 this ( @FunctionalInterface
) already exists (it is called Supplier
), so if you run your code under Java8 there is no need to define a user interface.
Also, if you run your code under some pre-Java8 version, you can use the Guava interface Supplier
.
+4
source to share