Reputation: 11377
Is there a way to refer static method that returns void?
i've tried this
public Function<Runnable, Void> runner = Platform::runLater;
but it will say "bad return type, cannot convert void to java.lang.Void"
Upvotes: 7
Views: 3481
Reputation: 393781
If your method has no return value, don't use the Function
interface.
Use Consumer<Runnable>
instead.
public Consumer<Runnable> runner = Platform::runLater;
It represents an operation that accepts a single input argument and returns no result.
Upvotes: 16