class Wow { Closure myCounter (int start) { return new ClosureImplementation(start);} public static void main(String[] args) { Wow w = new Wow(); Closure c = w.myCounter(15); Closure c2 = w.myCounter(2); c.apply(); c.apply(); c2.apply(); c.apply(); c.apply(); c2.apply(); c2.apply(); } class ClosureImplementation implements Closure { private int counter; ClosureImplementation(int start) { counter = start; } public void apply () {System.out.println(counter++);} } }