Wednesday, 3 September 2014

java 7 features


  1. Java 1.7 contains an important enhancement  for multithreaded custom class loaders. In previous releases, certain types of custom class loaders were prone to deadlock. The Java 1.7 release modifies the locking mechanism to avoid deadlock.
  2. Java 1.7 introduces a new JVM instruction called “invokedynamic”  that simplifies the implementation of dynamically typed programming languages .Thus Java 1.7 enables JVM support for the non-java language.
  3. In Java 1.7, the integral types (byte, short, int, and long) can also be expressed using the binary number system. To specify a binary literal, add the prefix 0b or 0B to the number.
For example:
?
1
2
3
4
5
6
// 8-bit 'byte' value:
byte num1 = (byte)0b00100010;
// 16-bit 'short' value:
short num1 = (short)0b1010000101000011;
// 32-bit 'int' values:
int num1 = 0b10100001010001011010000101000110;
4. In Java 1.7, you can use a String object in the expression of a switch statement.
5. Java 1.7 contains  a new version of JDBC  i.e. JDBC 4.1, introduces the following features:
  • Ability to use a try-with-resources statement to automatically close resources of type Connection, ResultSet, and Statement.
The following statement is a try-with-resources statement that declares one resource stmt, which will be automatically closed then the try block terminates:
     try (Statement stmt = con.createStatement())
      {
            // ...
      }
  • The introduction of the ‘RowSetFactory’ interface and the ‘RowSetProvider’ class, which enable you to create all types of row sets supported by your JDBC driver.
 6.  In Java1.7 and later, a single catch block can handle more than one type of exception.This feature          can reduce code duplication and lessen the temptation to catch an overly broad exception.
For example:
catch (IOException|SQLException ex)
 {
    ex.printStackTrace();
 }
7. Java 1.7 introduces “Garbage-First Collector” is a server-style garbage collector that replaces the          Concurrent Mark-Sweep Collector (CMS).
8. Early versions of the Java SE 7 release added support for Unicode 5.1.0. The final version of the          Java SE 7 release supports Unicode 6.0.0. Unicode 6.0.0 is a major version of the Unicode                    Standard    and adds support for over 2000 additional characters, as well as support for properties        and data files.
9. The Java 1.7  release  contains Java API for XML Processing (JAXP) 1.4.5.
10. In Java 1.7 and later, any number of underscore characters ( _ ) can appear anywhere between            digits in a numerical literal. This feature enables you to separate groups of digits in numeric literals,        which can improve the readability of your code.
For example:
long number = 123_456_789L;

No comments:

Post a Comment