Java 7 - New and Noteworthy
- Java 6 is outdated and will not be updated anymore. Using it is a security risk.
- Java 7 offers some great new features.
New and Noteworthy Features in Java 7
In this section MatthesRieke
quickly mention some features that shold become part of our daily software development because the considerably improve the code. More information can be found in the links at the bottom.
Use it instead of java.io - much easier to use and very useful (convenience) functionality for file and folder watching, file copying.
Base class to start with: Paths.java and it's static methods.
String switch statements
The same as int or enum switches, use it instead of if-else chains.
Java 7 can take care to "finally" close streams (interface AutoCloseable
) instead of manually haven if!=null and try with in a finally statement...
I could be harder to get the actual exception.
Make catch statements a lot easier to read and limit duplication of code and you are not tempted to capture the generic Exception.
Fork and join
... vll. Zur XML Erzeugung? Tasks mit xmlbeans, joins in stax...
If you have a task you can divide and conquer you can use the fork/join framework to manage this task in many threads.
Makes instantiations short and readable (can even be warned about by the compiler): Write
Map<String, List<Trade>> trades = new TreeMap <> ();
Map<String, List<Trade>> trades = new TreeMap <String, List<Trade>> ();
More Resources and Documentation