Capture Demo

PHOTO EMBED

Wed May 29 2024 19:18:15 GMT+0000 (Coordinated Universal Time)

Saved by @exam123

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()); 
	}

}
content_copyCOPY