首页javalambda_interfaceJava Stream - 如何从接口调用默认方法和lambda方法

Java Stream - 如何从接口调用默认方法和lambda方法

我们想知道如何从接口调用默认方法和lambda方法。
public class Main {

    public static void main(String[] args) {

        ChildInterface def = (s) -> {
            System.out.println("lambda: " + s);
        };
        def.doIt();
        def.likeIt("I like the IExtended..");
    }
}

interface ChildInterface extends ParentInterface {

    public default void doIt() {
        System.out.println("my extended doIt function..");
    }
}

interface ParentInterface {
    public void likeIt(String s);
    public default void doIt() {
        System.out.println("doIt function..");
    }
}