Language  New Features – Project Coin – JSR 334
Earlier public String getPostalCode(Person person) { if (person != null)  { Address  address = person.getAddress(); if (address != null) { return address.getPostalCode(); } } return null; } Now public String getPostalCode(Person person) { return  person ? .getAddress() ? . getPostalCode() ; } Use Null-safe operator  ‘?.’ in Java 7.
Earlier public void process() { try { } catch (Exception one) { // do something } catch (Exception two) { // do something else } catch (Exception three) { // do something } } Now public void process() { try { } catch ( Exception one |  Exception three ) { // do something } catch (Exception two) { // do something else }  } If in two exception blocks you’re doing same thing you can  use ‘|’ operator to join them in java 7.
Earlier public void writeContent(String fileName, String content)  throws YourException { FileOutputStream  fileOutputStream  = null; DataOutputStream  dataOutputStream  = null; try { fileOutputStream = new FileOutputStream (fileName); dataOutputStream  = new DataOutputStream (fileOutputStream ); dataOutputStream .writeUTF(content); }  catch (IOException ioException) { throw new YourException(ioException.getMessage(), ioException); }  finally { try { if (fileOutputStream != null) {   fileOutputStream .close(); } if (dataOutputStream != null) { dataOutputStream .close(); } } catch (IOException ioException) { //Log the exception } } }
Now public void writeContent(String fileName, String content)  throws YourException { FileOutputStream  fileOutputStream  = null; DataOutputStream  dataOutputStream  = null; try  ( fileOutputStream = new FileOutputStream (fileName); dataOutputStream  = new DataOutputStream (fileOutputStream ); )  { dataOutputStream .writeUTF(content); }  catch (IOException ioException) { throw new YourException(ioException.getMessage(), ioException); }  } Look at the content written in brackets after try. All of  the open resources  are automatically managed. So, no open connections, resultset, file issues   .
Earlier Map<String,Integer> map = new HashMap<String, Integer>(); Now Map<String,Integer> map = new HashMap <> (); No need to repeat <String, Integer> again.
Collections can be used as Arrays e.g. List <String> itemList = [“item1”,”item2”]; String item = itemList[0]; Map<String, Integer> map = [“item1”:1,”item2”:2]
You can use switch case for Strings as well. Remember: It will use equals() method for comparison and not equalIgnoreCase() method.
Though not of much use for most of the developers, but still good to mention. 4 key rules to be used with Numeric literals for using underscore: Underscores can't go at the beginning or the end of a number. You can't use an underscore on either side of a decimal.  The underscore cannot go before an identifying suffix such as F, D or L You can't put an underscore before or after the binary or hexadecimal identifiers b and x.
Valid Examples double var1 = 1_23.456D; float var2 = 123.45_6F; long var3 = 1010_0101_1010L; int hexed = 0xBASE_01; Invalid Examples double var1 = 123_.456D; float var2 = 123.456_F; long var3 = 1010_0101_1010_L; int hexed = 0_x_BASE_01;
vm Compressed 64-bit object pointers Garbage-First GC (G1) JSR 292: VM support for non-Java languages (InvokeDynamic) Strict class file checking lang – Project Coin JSR 334 already covered
core Upgraded class-loaded architecture Method to close a URLClassLoader Concurrency and Collections updates i18n Unicode 6.0 Locale enhancemements Separate user locale and user-interface locale
ionet JSR 203: More new I/O APIs for the Java platform (NIO.2)NIO.2 file system provider for zip/jar archives Other platform oriented changes such as SCTP and SDP. Sec Elliptic-curve cryptography (ECC) Jdbc 4.1
client XRender pipeline for Java 2D Create new platform APIs for 6u10 graphics features Nimbus look-and-feel for Swing Swing JLayer component Gervill sound synthesizer web Update the XML stack mgmt Enhanced Mbeans Refer to  http://openjdk.java.net/projects/jdk7/features/  for details
 

Java 7

  • 1.
    Language NewFeatures – Project Coin – JSR 334
  • 2.
    Earlier public StringgetPostalCode(Person person) { if (person != null) { Address address = person.getAddress(); if (address != null) { return address.getPostalCode(); } } return null; } Now public String getPostalCode(Person person) { return person ? .getAddress() ? . getPostalCode() ; } Use Null-safe operator ‘?.’ in Java 7.
  • 3.
    Earlier public voidprocess() { try { } catch (Exception one) { // do something } catch (Exception two) { // do something else } catch (Exception three) { // do something } } Now public void process() { try { } catch ( Exception one | Exception three ) { // do something } catch (Exception two) { // do something else } } If in two exception blocks you’re doing same thing you can use ‘|’ operator to join them in java 7.
  • 4.
    Earlier public voidwriteContent(String fileName, String content) throws YourException { FileOutputStream fileOutputStream = null; DataOutputStream dataOutputStream = null; try { fileOutputStream = new FileOutputStream (fileName); dataOutputStream = new DataOutputStream (fileOutputStream ); dataOutputStream .writeUTF(content); } catch (IOException ioException) { throw new YourException(ioException.getMessage(), ioException); } finally { try { if (fileOutputStream != null) { fileOutputStream .close(); } if (dataOutputStream != null) { dataOutputStream .close(); } } catch (IOException ioException) { //Log the exception } } }
  • 5.
    Now public voidwriteContent(String fileName, String content) throws YourException { FileOutputStream fileOutputStream = null; DataOutputStream dataOutputStream = null; try ( fileOutputStream = new FileOutputStream (fileName); dataOutputStream = new DataOutputStream (fileOutputStream ); ) { dataOutputStream .writeUTF(content); } catch (IOException ioException) { throw new YourException(ioException.getMessage(), ioException); } } Look at the content written in brackets after try. All of the open resources are automatically managed. So, no open connections, resultset, file issues  .
  • 6.
    Earlier Map<String,Integer> map= new HashMap<String, Integer>(); Now Map<String,Integer> map = new HashMap <> (); No need to repeat <String, Integer> again.
  • 7.
    Collections can beused as Arrays e.g. List <String> itemList = [“item1”,”item2”]; String item = itemList[0]; Map<String, Integer> map = [“item1”:1,”item2”:2]
  • 8.
    You can useswitch case for Strings as well. Remember: It will use equals() method for comparison and not equalIgnoreCase() method.
  • 9.
    Though not ofmuch use for most of the developers, but still good to mention. 4 key rules to be used with Numeric literals for using underscore: Underscores can't go at the beginning or the end of a number. You can't use an underscore on either side of a decimal.  The underscore cannot go before an identifying suffix such as F, D or L You can't put an underscore before or after the binary or hexadecimal identifiers b and x.
  • 10.
    Valid Examples doublevar1 = 1_23.456D; float var2 = 123.45_6F; long var3 = 1010_0101_1010L; int hexed = 0xBASE_01; Invalid Examples double var1 = 123_.456D; float var2 = 123.456_F; long var3 = 1010_0101_1010_L; int hexed = 0_x_BASE_01;
  • 11.
    vm Compressed 64-bitobject pointers Garbage-First GC (G1) JSR 292: VM support for non-Java languages (InvokeDynamic) Strict class file checking lang – Project Coin JSR 334 already covered
  • 12.
    core Upgraded class-loadedarchitecture Method to close a URLClassLoader Concurrency and Collections updates i18n Unicode 6.0 Locale enhancemements Separate user locale and user-interface locale
  • 13.
    ionet JSR 203:More new I/O APIs for the Java platform (NIO.2)NIO.2 file system provider for zip/jar archives Other platform oriented changes such as SCTP and SDP. Sec Elliptic-curve cryptography (ECC) Jdbc 4.1
  • 14.
    client XRender pipelinefor Java 2D Create new platform APIs for 6u10 graphics features Nimbus look-and-feel for Swing Swing JLayer component Gervill sound synthesizer web Update the XML stack mgmt Enhanced Mbeans Refer to http://openjdk.java.net/projects/jdk7/features/ for details
  • 15.