Wednesday, 10 December 2008

What next in Java 7?

Good article on adding closures to Java. An interesting comparison is made between closures and inner classes. The article is by Angelika Langer. Closures are a very beautiful way of implementing mathematics. For example, a bisection algorithm can be elegantly implemented with closures.

To understand the limitations of inner classes versus closures we need to understand exactly the rules for inner classes in Java. An inner class can just a private class inside another class (like an embedded struct). Anonymous inner classes are used when creating ActionListeners e.g. button.addActionListener( new ActionListener() {} ).

No comments:

Blog Archive