Java 7 and the Elvis operator

With Java 6 out for quite a while now, Java 7 is finally looming closer for a release due in early 2010. Most of the big changes are either scrapped (like support for closures or a standard module system), or actually pushed into a Java 6 update (the new G1 garbage collector is coming in update 14).

Not all is lost on Java 7 though. Along with several API updates and JVM/tooling improvements, there are also some language changes expected. These are gathered in "Project Coin". The clever name implies that each proposal involves "small" change, and refers to the proverb "to coin a phrase".

One of the proposals is the new "Elvis" operator. It involves using the question mark as a shorthand to check for null scenarios. One of the expressions is this one:

?:

If you look sideways, it's Elvis! I really am not that fond about this kind of programming, but having something called the Elvis operator as a new feature is reason enough for me to migrate asap. 😉 I hope other language additions will get a similarly cool name.