Some of the JDK 1.7 Improvements in a Nutshell
Join the DZone community and get the full member experience.
Join For FreeFollowing 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<>();
Opinions expressed by DZone contributors are their own.
Comments