2.Write a java program that returns the value of pi using the lambda expression.

PHOTO EMBED

Sun May 26 2024 20:21:22 GMT+0000 (Coordinated Universal Time)

Saved by @prabhas

public class PiLambdaExpression{
    @FunctionalInterface
    interface PiValue{
        double getPi();
    }
    public static void main(String[] args) {
        PiValue pi = () -> Math.PI;
        double p= pi.getPi();
        System.out.println("The value of Pi is: " + p);
    }
}
content_copyCOPY