All Java people are looking forward to jdk8 to bring more functional-like syntax to the language, but it will take some time before we’ll really be able to code like that day to day. It may take years, before jdk8 gets fully adopted as a standard (how many of you already use jdk7 in production these days?) Till then, we’ll still have to write all the verbose code around – if you want to stick with Java language, of course.

Want to try how it will look like in your code today? Get IntelliJ IDEA 12. This is how my source code looks in it (Java 1.6.0_38-b05):


When I hover the grayed code, real syntax comes up:


Pretty cool, huh?

Extremely improves readability, when your anonymous class method’s body is just one line return statement. And that’s pretty often, when you’re e.g. mocking method calls in unit tests.

This was originally posted on blogger here.