Java 8 Lambda function that throws exception?

后端 未结 26 2031
臣服心动
臣服心动 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:42

    This is not specific to Java 8. You are trying to compile something equivalent to:

    interface I {
        void m();
    }
    class C implements I {
        public void m() throws Exception {} //can't compile
    }
    

提交回复
热议问题