Lambda Function Inside Method

Lambda Function Inside Method

As in previous example you saw how to use Function interface. In this simple example you will see how use Function inside the method. Here we will pass one double parameter and will multiple the data and print the result on the console:

  • LambdaFunctionCall.java:
package com.javahonk;

import java.util.function.Function;

public class LambdaFunctionCall {

	public static void main(String[] args) {
		
		Function<Double, Double> multiplication = value -> value * 5;
		
		System.out.println("Result multiplication of 5 :"+multiplication.apply(22.22));

	}

}
  • Output:

Lambda Function Inside Method

  • For more details please visit Oracle documentation here

Leave a Reply

Your email address will not be published. Required fields are marked *