interface Counter {
int next();
}
public class MainClass{
private int count = 0;
Counter getCounter(final String name) {
return new Counter() {
{
System.out.println("Counter()");
}
public int next() {
System.out.print(name); // Access local final
return count++;
}
};
}
public static void main(String[] args) {
MainClass lic = new MainClass();
Counter c1 = lic.getCounter("Local inner ");
}
}
|