I have come across Java code in this form for the first time:
object.methodA(new ISomeName() {
public void someMethod() {
//some code
}
});
It's creating an anonymous class.
Note that within anonymous class, you can refer to final local variables from within the earlier code of the method, including final parameters:
final String name = getName();
Thread t = new Thread(new Runnable() {
@Override public void run() {
System.out.println(name);
}
});
t.start();
The values of the variables are passed into the constructor of the anonymous class. This is a weak form of closures (weak because of the restrictions: only values are copied, which is why the variable has to be final).