6

有没有办法引用返回 void 的静态方法?

我试过这个

public Function<Runnable, Void> runner = Platform::runLater;

但它会说“返回类型错误,无法将 void 转换为 java.lang.Void”

4

1 回答 1

15

如果您的方法没有返回值,请不要使用Function接口。

请改用消费者<Runnable>

public Consumer<Runnable> runner = Platform::runLater;

represents an operation that accepts a single input argument and returns no result.

于 2014-10-23T09:04:22.103 回答