首页javalambda_interfaceJava Stream - 如何覆盖默认方法

Java Stream - 如何覆盖默认方法

我们想知道如何覆盖默认方法。
public class Main {
  public static void main(String[] args) {
    HelloInterface hello = new My();
    hello.hello();
  }

}

@FunctionalInterface
interface SimpleFuncInterface {
  public void doWork();
}

interface HelloInterface {
  public default void hello() {
    System.out.println("default hello");
  }
}

class My implements HelloInterface {

  @Override
  public void hello() {
    System.out.println("hello melin");
  }

}