【发布时间】:2016-08-10 07:55:42
【问题描述】:
我很好奇为什么不能将具有返回类型的 lambda 转换为 Runnable 而非 void 方法引用可以。
Runnable r1 = () -> 1; // not allowed
// error: incompatible types: bad return type in lambda expression
// int cannot be converted to void
Runnable r2 = ((Supplier)() -> 1)::get; // allowed
【问题讨论】: