Is there an interface similar to Callable but with arguments?

后端 未结 8 1584
小蘑菇
小蘑菇 2021-01-31 02:03

Is there an interface in Java similar to the Callable interface, that can accept an argument to its call method?

Like so:

public interface M         


        
8条回答
  •  遥遥无期
    2021-01-31 02:14

    Since Java 1.8 there is a Supplier interface. It has a get() method instead of call() and it does not declare any Exception thrown.

提交回复
热议问题