Java 8 Lambda function that throws exception?

后端 未结 26 1728
臣服心动
臣服心动 2020-11-22 03:14

I know how to create a reference to a method that has a String parameter and returns an int, it\'s:

Function         


        
26条回答
  •  醉话见心
    2020-11-22 03:30

    You can use unthrow wrapper

    Function func1 = s -> Unthrow.wrap(() -> myMethod(s));
    

    or

    Function func2 = s1 -> Unthrow.wrap((s2) -> myMethod(s2), s1);
    

提交回复
热议问题