Skip to content

JAVA 7 is out

September 12, 2011

First version of JAVA from Oracle. JAVA 7 is available. There are 2 differents things very interesting about the syntax (other stuff like a brand new I/O API with a native file copy are also available).

Strings switch

It is new (even C/C++ does not include this feature) and very useful. From now, You can directly use the strings as arguments for the results of a switch:

switch( cheese ){
  case "Camembert" : return FRANCE;
  case "Cheddar" : return UNITED_KINGDOM;

It is a revolution. I hope they use the hash code of the strings to optimize the switch (I don’t know) but in any case, it is a very useful way to work with simple text analysis.

A complete example can be found at  (see also the end of the page of the Java tutorial).

Multiple throw

Another frustrating syntax was linked to the try/catch. Especially when you want to catch multiple exceptions related to the same stuff (XML parsing for example can generate several type of exceptions, same when you use introspection).

Now, you can catch several exceptions by using the pipe (“|”) character. You can then write:

try { 
 catch( DOMException|ParseException ex ){


OpenJDK is now available in version 7. Then open source is not yet broken by Oracle. Note the OpenJDK is not available for Windows where the official Sun release is the only available.


From → Other

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: