[英]Java 8 method reference to static void method
Is there a way to refer static method that returns void? 有没有办法引用返回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" 但它会说“错误的返回类型,无法将void转换为java.lang.Void”
If your method has no return value, don't use the Function
interface. 如果您的方法没有返回值,请不要使用
Function
接口。
Use Consumer <Runnable>
instead. 请改用Consumer
<Runnable>
。
public Consumer<Runnable> runner = Platform::runLater;
It represents an operation that accepts a single input argument and returns no result.
它
represents an operation that accepts a single input argument and returns no result.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.