SyntaxHighlighter

Tuesday, July 5, 2011

Java 7 New Features

Following are few new features of Java 7

1. Introduction of WatchService? (NIO)

A watch service that watches registered objects for changes and events. For example a file manager may use a watch service to monitor a directory for changes so that it can update its display of the list of files when files are created or deleted.

2. Strings in Java Switch construct
Will be able to String case based switch constructt; prior to java 7 switch was only allowed with int & enums

3. Introduction of autoclosable interface and try with resource construct
Developers will get rid of closing resources in finally block. JDBC 4.1 has accomodated these constructs in their classes.
4. Underscores in Numbers
Increasing readability of numbers.
int phoneNumber = 555_555_1212;
long creditCardNumber = 1234_5678_9012_3456L;
long socialSecurityNumbers = 999_99_9999L;
float monetaryAmount = 12_345_132.12;
long hexBytes = 0xFF_EC_DE_5E;

5. Introduction of Closures
Much awaited & requested closures are part of JDK7 on experimental basis ,RI for it will be included in JDK8 TCK as per JSR


6 Addition of forkJoin for parallel processing
Combined JSR 166 into JDK

No comments: