In the below code Calculator class implementation will have access to b variable even its not in the scope. This is done by java compiler having a copy of b variable and sending to the calculator class.

Photo by Yves Alarie on Unsplash
int a=10;
int b=20;
operate(a, new Calculator() {
@Override
public void process(int i) {
System.out.println(i + " - " + b);
}
});