@FunctionalInterface interface PiProvider { double getPi(); } public class PiLambda { public static void main(String[] args) { // Lambda expression to return the value of Pi PiProvider piProvider = () -> Math.PI; // Invoke the lambda expression and print the value of Pi double piValue = piProvider.getPi(); System.out.println("The value of Pi is: " + piValue); } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter