Java 8 lambda Void argument

前端 未结 9 625
臣服心动
臣服心动 2020-12-12 08:30

Let\'s say I have the following functional interface in Java 8:

interface Action {
   U execute(T t);
}

And for some cases I ne

9条回答
  •  醉梦人生
    2020-12-12 09:29

    Use Supplier if it takes nothing, but returns something.

    Use Consumer if it takes something, but returns nothing.

    Use Callable if it returns a result and might throw (most akin to Thunk in general CS terms).

    Use Runnable if it does neither and cannot throw.

提交回复
热议问题