Additon using lambda expression


Here we are going to create a addition functional interface, and going to use lamda expression in LambdaTest class. First create a functional interface:



package Java8Practice;

@FunctionalInterface
public interface additon {
		public void add(int a, int b);
}

Now create LambdaTest class:


package Java8Practice;

public class LambdaAddition {
	public static void main(String[] args)
	{
      additon a1 = (a,b) -> System.out.println("addition is" + (a + b));
      a1.add(3,5);
	}
}

Here Output is :

addition is 8