Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Some of the JDK 1.7 Improvements in a Nutshell

DZone's Guide to

Some of the JDK 1.7 Improvements in a Nutshell

· DevOps Zone ·
Free Resource

Planning to extract out a few microservices from your monolith? Read this free guide to learn the best practice before you get started.

Following are the top 10 improvements impressed me over previous version of JDK. In a nutshell, I summarized below for quick look up.

  •  Underscores in Numeric Literals
   long ssn = 999_99_9999L
  • Strings in Switch Statements
String month = "Feb";
  switch(month) {
     case "January"  : <do some thing> ;break;
     case "February" : <do some thing> ;break;
     default : <do some thing> ;break;
  }
  • Automatic Resource Management

  Inout/Ouput streams need not be closed explicitly. JVM will take care of closing them when needed.

  Extended to classes which implements java.lang.AutoCloseable

  Syntax:

try( InputStream in = new FileInputStream(new File("text.txt"))){
     // your code
}
  • Multi-Catch Statements - group relevant types
try{
   ...
  } catch(InstantiationException | NoSuchMethodException | InvocationTargetException e){
     log(e);
  }     
  • New Enhanced IO package(NIO2)

Some of the new classes: java.nio.file.Paths, java.nio.file.Files, java.nio.file.FileSystem

features added to watch a directory for any changes, create a symbolic links, file copy is made easy.

  • Enhanced Concurrancy API
  • Bug Fixes on JAXP, JAX-WS, JAXB
  • JDBC 4.1

Connection, ResultSet and Statement = > now we don't need to close them manually as they implement AutoCloseable interface.

  • Fork and Join Framework
  • Diamond operator works many ways.
  Foo<Bar> bar=new Foo<>();


Learn how to measure the impact of every feature release on performance and customer experience metrics.

Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}