public interface MyNum{
public abstract double getNum();
}
public class LambdaDemo{
public static void main(String[] args){
MyNum.num=()->123.456;
S.o.p("This is the value:"+num.getNum());
num->Math.random()*100;
S.o.p("This is random value:"+num.getNum());
S.o.p("This is one more random value:"+num.getNum());
}
}
OUTPUT:
123.456
420
640
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