Create Lambda expression for your own FunctionalInterface - Java Lambda Stream

Java examples for Lambda Stream:Functional Interface

Description

Create Lambda expression for your own FunctionalInterface

Demo Code



public class LamdaMain2 {
  public static void main(String[] args) {
    MathOperations mathOperations = (a, b) -> System.out.println("Sum:" + (a + b));
    mathOperations.operation(2, 3);/* w  ww  .  j  a v  a 2 s.  c  o  m*/
    MathOperations mathOperations1 = (a, b) -> System.out.println("Subtract:" + (a - b));
    mathOperations1.operation(2, 3);
  }

  @FunctionalInterface
  interface MathOperations {
    void operation(int a, int b);
  }
}

Related Tutorials