class Test { | |
void foo() { | |
int x = 0; | |
Inner inner = new Inner(x).invoke(); | |
x = inner.getX(); | |
int y = x; | |
System.out.println(x + y); | |
} | |
private class Inner { | |
private int x; | |
public Inner(int x) { | |
this.x = x; | |
} | |
public int getX() { | |
return x; | |
} | |
public Inner invoke() { | |
x++; | |
return this; | |
} | |
} | |
} |