Lambda can only be used with functional interface?

前端 未结 4 1445
盖世英雄少女心
盖世英雄少女心 2020-12-13 20:26

I did this:

public class LambdaConflict
{
    public static void main(String args[]){
        //*
        System.out.println(LambdaConflict.get(
                     


        
4条回答
  •  粉色の甜心
    2020-12-13 21:18

    As stated by @Thomas-Uhrig, Functional Interfaces can only have one method.

    A way to fix this, primarily because you never use public T get2(T arg1);, is to change the Intf interface to:

    @FunctionalInterface
    interface Intf
    {
        public T get1(T arg1);
    }
    

提交回复
热议问题