Add default value to interface - Java Lambda Stream

Java examples for Lambda Stream:Functional Interface

Description

Add default value to interface

Demo Code



public class DefaultMethodDemo {
  public static void main(String[] args) {
    new Test().show();
  }/*from w  w w. j av a 2 s  .  c o  m*/

}

class Test implements DefaultInterface1, DefaultInterface2 {
  @Override
  public void show() {
    DefaultInterface1.super.show();
    DefaultInterface2.super.show();
    System.out.println("THis is Impelmentation");
  }
}

interface DefaultInterface1 {
  default void show() {
    System.out.println("THis is first Impelmentation");
  }
}

interface DefaultInterface2 {
  default void show() {
    System.out.println("THis is Second Impelmentation");
  }
}

Related Tutorials