You are here: Wiki>Documentation Web>Java7NewAndNoteworthy (27 Mar 2015, AnnHitchcock)Edit Attach

Java 7 - New and Noteworthy


Why bother?

  1. Java 6 is outdated and will not be updated anymore. Using it is a security risk.
  2. Java 7 offers some great new features.

New and Noteworthy Features in Java 7

In this section MatthesRieke and DanielNuest 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.

java.nio

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.

More info:

String switch statements

The same as int or enum switches, use it instead of if-else chains.

try-with-resource

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.

Multicatch

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.

See http://docs.oracle.com/javase/tutorial/essential/concurrency/forkjoin.html

Diamond Operator

Makes instantiations short and readable (can even be warned about by the compiler): Write

Map<String, List<Trade>> trades = new TreeMap <> ();

instead of

Map<String, List<Trade>> trades = new TreeMap <String, List<Trade>> ();.

More Resources and Documentation

Topic revision: r7 - 27 Mar 2015, AnnHitchcock
Legal Notice | Privacy Statement


This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Wiki? Send feedback