Java SE 7 New Features &EnhancementsFu Cheng @alexcheng1982
Author of Understanding the Java 7 Author of technical articles on
Agenda• Usefull tips– Language– IO• No deep dive topics
Why Java Platform
Why Javahttp://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
Why Java• Easy to learn– Simple• Easy to use– Strong community– All kinds of third-party libraries• HARD to do things WRON...
Why Java 7• 5 years from Java SE 6 to Java SE 7• New features– JVM level– Language level– API• Enhancements– Performance– ...
String in Switch• “switch” statement• Prior to Java 7– Can only use data type compatible with integer in“switch”• Java 7– ...
Sample
Numeric Literals• Java only supports literals of primitive types– List & map literals – Java SE 8 (maybe)• Binary literals...
Exception Handling• Multiple exception types in one catch clause
try-with-resources• Use try clause to manage resources– “finally” not required– Resource released automatically• Make you ...
SampleFile copy example
Diamond Operator• Use diamond (<>) operator to simply genericobjects creationOld wayNew way
Path• java.nio.file.Path– New abstraction for file path– Say goodbye to using string for file path– Type safe
Directory Stream• java.nio.file.DirectoryStream• List files in directory• Provide better performance than “File.list” and ...
Directory Watcher• Get notified when files changed in a directory– Entry created, modified or deleted
Those Not Included• JSR 292 – “invokedynamic” instruction• Concurrency utilities– Fork/join framework– Phaser• I18N– Unico...
Future of Java• Productivity– Enhanced for loop (Java SE 5)– try-with-resources (Java SE 7)– Diamond operator (Java SE 7)–...
Upcoming SlideShare
Loading in …5
×

Java SE 7 New Features and Enhancements

2,236 views

Published on

Java SE 7 New Features and Enhancements

Published in: Technology, News & Politics
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,236
On SlideShare
0
From Embeds
0
Number of Embeds
44
Actions
Shares
0
Downloads
51
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Java SE 7 New Features and Enhancements

  1. 1. Java SE 7 New Features &EnhancementsFu Cheng @alexcheng1982
  2. 2. Author of Understanding the Java 7 Author of technical articles on
  3. 3. Agenda• Usefull tips– Language– IO• No deep dive topics
  4. 4. Why Java Platform
  5. 5. Why Javahttp://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
  6. 6. Why Java• Easy to learn– Simple• Easy to use– Strong community– All kinds of third-party libraries• HARD to do things WRONG– Static typed– Rigid syntax
  7. 7. Why Java 7• 5 years from Java SE 6 to Java SE 7• New features– JVM level– Language level– API• Enhancements– Performance– Management– Documentation
  8. 8. String in Switch• “switch” statement• Prior to Java 7– Can only use data type compatible with integer in“switch”• Java 7– String type is allowed• Under the hood– Switch by string hash code
  9. 9. Sample
  10. 10. Numeric Literals• Java only supports literals of primitive types– List & map literals – Java SE 8 (maybe)• Binary literals– Prefixed with 0b or 0B• 0b001001• Underscores in literals– Align for readability• 5_6.3_4
  11. 11. Exception Handling• Multiple exception types in one catch clause
  12. 12. try-with-resources• Use try clause to manage resources– “finally” not required– Resource released automatically• Make you own resource manageable by tryclause– Implement java.lang.AutoCloseable– “close”method invoked automatically
  13. 13. SampleFile copy example
  14. 14. Diamond Operator• Use diamond (<>) operator to simply genericobjects creationOld wayNew way
  15. 15. Path• java.nio.file.Path– New abstraction for file path– Say goodbye to using string for file path– Type safe
  16. 16. Directory Stream• java.nio.file.DirectoryStream• List files in directory• Provide better performance than “File.list” and “File.listFiles”• Extend from Iterable
  17. 17. Directory Watcher• Get notified when files changed in a directory– Entry created, modified or deleted
  18. 18. Those Not Included• JSR 292 – “invokedynamic” instruction• Concurrency utilities– Fork/join framework– Phaser• I18N– Unicode 6.0– IETF BCP 47• NIO.2– Zip/jar file system– Async I/O• JDBC 4.1
  19. 19. Future of Java• Productivity– Enhanced for loop (Java SE 5)– try-with-resources (Java SE 7)– Diamond operator (Java SE 7)– Lambda expression (Java SE 8)• Performance– Fork/join framework (Java SE 7)– Collection framework enhancements (Java SE 8)• Modularization– Project Jigsaw (Java SE 8)

×