这个问题在这里已经有了答案:MethodReference-passingFunctiontomethodwithConsumerargument(2个答案)关闭4年前。我在Utils中有以下可用方法类:protectedUwithTx(Functionfc){//dosomethingwiththefunction}protectedvoidwithTx(Consumerconsumer){withTx(g->{consumer.accept(g);returnnull;});}并且在myClass的方法中我有:withTx(g->anotherMethod(g));第二段代码编译错