public class LambdaDemo { public static void main(String[] args) { MyNum num = () -> 123.456; System.out.println("This is the value: " + num.getNum()); num = () -> Math.random() * 100; System.out.println("This is the random value: " + num.getNum()); System.out.println("This is one more random value: " + num.getNum()); } }
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