interface Capture
{ int compute(int n); }
public class CaptureDemo
{ private int a = 100;
public int getA(){ return this.a; }
public static void main(String[] args)
{
CaptureDemo c1 = new CaptureDemo();
System.out.println("Value: "+c1.getA());
int x = 200;
Capture ob = (n)-> {
int z = 12;
int result = z + n + x + c1.getA();
c1.a = 9876;
//x++;
return result;
};
System.out.println(ob.compute(40));
System.out.println("Value: "+c1.getA());
}
}
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