JAVA 7 is out
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 http://download.oracle.com/javase/tutorial/java/nutsandbolts/examples/StringSwitchDemo.java (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
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.
No comments yet.
Leave a Reply
-
Archives
- October 2011 (1)
- September 2011 (7)
- April 2011 (1)
- February 2011 (1)
- January 2011 (1)
- December 2010 (1)
- October 2010 (1)
- August 2010 (3)
- July 2010 (1)
- February 2010 (2)
- January 2010 (3)
- July 2009 (1)
-
Categories
-
RSS
Entries RSS
Comments RSS
