SlideShare a Scribd company logo
1 of 20
  Tossing the Project Coin!   Marimuthu Rajagopal
Java Version History Language Enhancement Version Release Date Language Enhancement JDK 1.0 Jan 23, 1996 (Initial Release)Oak JDK 1.1 Feb 19,1997 Inner Class ,Reflection,JavaBeans,JDBC,RMI J2SE 1.2 Dec 8, 1998 Strictfp, Collection frame work J2SE 1.3 May 8,2000 Hotspot JVM,JNDI,JPDA J2SE 1.4 Feb 6,2002 Assert, Regular expression,exception chaining. J2SE 1.5 Sep 30,2004 Generics,annotation,auto  boxing,Enumeration,Var  args,for each,staticimport Java SE 6 Dec 11,2006 Scripting  Language Support,Performance Improvement Java SE 7 July 07,2011 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Java SE 8 ,[object Object]
Java 7 Language Enhancement(Project Coin) JSR 334 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
String in Switch ,[object Object],[object Object],[object Object],[object Object],http://download.java.net/jdk7/docs/technotes/guides/language/strings-switch.html   http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.28  http://java.sun.com/docs/books/jls/second_edition/html/expressions.doc.html#5313
String in Switch Java 6 and Prior public static String getTypeOfDayWithSwitchStatement(String dayOfWeekArg) { String typeOfDay="";  if(dayOfWeekArg.equals("Monday")) typeOfDay="Start of Work week"; else if(dayOfWeekArg.equals("Tuesday")|| dayOfWeekArg.equals("Wednesday")|| dayOfWeekArg.equals("Thursday")) typeOfDay="Midweek"; else if(dayOfWeekArg.equals("Friday")) typeOfDay="End of work week"; else if(dayOfWeekArg.equals("Saturday")|| dayOfWeekArg.equals("Sunday")) typeOfDay="Week off"; else typeOfDay="Invalid day"; return typeOfDay; } http://download.java.net/jdk7/docs/technotes/guides/language/strings-switch.html
String in Switch Java 7 public static String getTypeOfDayWithSwitchStatement(String dayOfWeekArg) { String typeOfDay="";  switch (dayOfWeekArg) { case "Monday": typeOfDay="Start of Work week"; break; case "Tuesday": case "Wednesday": case "Thursday": typeOfDay="Midweek"; break; case "Friday": typeOfDay="End of work week"; break; case "Saturday": case "Sunday": typeOfDay="Week off"; break; default: typeOfDay="Invalid day"; break; } return typeOfDay;  } http://download.java.net/jdk7/docs/technotes/guides/language/strings-switch.html
Binary literal & Underscore in literal ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],http://download.java.net/jdk7/docs/technotes/guides/language/binary-literals.html http://download.java.net/jdk7/docs/technotes/guides/language/underscores-literals.html
Binary literal & Underscore in literal ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Multi-Catch and More precise rethrow. ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],http://download.java.net/jdk7/docs/technotes/guides/language/catch-multiple.html
Multi-Catch. Java 6 and Prior   try{ // Method method=Object.class.getMethod("toString"); final Class[] ARG_TYPE=new Class[]{String.class}; Method method=Integer.class.getMethod("parseInt",ARG_TYPE); Object result=method.invoke(null,new Object[]{new String("44")}); System.out.println("result:"+result.toString()); } catch(NoSuchMethodException e) { e.printStackTrace(); }catch(IllegalAccessException e) { e.printStackTrace(); } catch(InvocationTargetException e) { e.printStackTrace(); }
Multi-Catch. Java 7 try{ // Method method=Object.class.getMethod("toString"); final Class[] ARG_TYPE=new Class[]{String.class}; Method method=Integer.class.getMethod("parseInt",ARG_TYPE); Object result=method.invoke(null,new Object[]{new String("44")}); System.out.println("result:"+result.toString()); } catch( NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { e.printStackTrace(); }
More precise rethrow. Java 6 and Prior public static void precise() throws NoSuchMethodException, IllegalAccessException { try{ // Method method=Object.class.getMethod("toString"); final Class[] ARG_TYPE=new Class[]{String.class}; Method method=Integer.class.getMethod("parseInt",ARG_TYPE); Object result=method.invoke(null,new Object[]{new String("44")}); System.out.println("result:"+result.toString()); } catch(Exception e) { throw  new NoSuchMethodException(); } }
More precise rethrow. Java 7 public static void precise() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { try{ // Method method=Object.class.getMethod("toString"); final Class[] ARG_TYPE=new Class[]{String.class}; Method method=Integer.class.getMethod("parseInt",ARG_TYPE); Object result=method.invoke(null,new Object[]{new String("44")}); System.out.println("result:"+result.toString()); } catch(ReflectiveOperationException e) { throw e; } }
Try-with-Resources statement. ,[object Object],[object Object],[object Object],[object Object],[object Object],http://download.java.net/jdk7/docs/technotes/guides/language/catch-multiple.html
Try-with-Resources statement. Java 6 and Prior static void jdk16writeFile(String path)  { BufferedWriter bw = null; try  { bw=new BufferedWriter(new FileWriter(path)); bw.write("JDK1.6 Need to close resource manualy."); }catch(IOException e) { e.printStackTrace(); } finally { try { bw.close(); } catch (IOException ex) { ex.printStackTrace(); } } }
Try-with-Resources statement. Java 7 static void jdk17writeFile(String path) { try (BufferedWriter bw = new BufferedWriter(new FileWriter(path))) { bw.write("Welcome to JDK1.7 Try with resource concept"); } catch(IOException ex) ‏ { System.out.println("ex"+ex); } }
Diamond Operator(Type Inference for Generic Instance Creation) ‏ ,[object Object],[object Object],[object Object],[object Object],http://download.java.net/jdk7/docs/technotes/guides/language/catch-multiple.html
Diamond Operator(Type Inference for Generic Instance Creation) ‏ In Java 6 and Prior List<String> jvmLanguages=new ArrayList<String>(); In Java 7 List<String> jvmLanguages=new ArrayList<>(); jvmLanguages.add(&quot;Groovy&quot;); jvmLanguages.add(&quot;Scala&quot;); System.out.println(jvmLanguages); Type Inference List<?> typeinference=new ArrayList<> ();
Improved compiler warnings for Varargs ,[object Object],[object Object],[object Object],[object Object],[object Object]
Thank you Q&A    e-mail :muthu.svm@gmail.com  blog :http://microtechinfo.blogspot.com

More Related Content

What's hot

スローダウン、ハングを一発解決 スレッドダンプはトラブルシューティングの味方 #wlstudy
スローダウン、ハングを一発解決 スレッドダンプはトラブルシューティングの味方 #wlstudyスローダウン、ハングを一発解決 スレッドダンプはトラブルシューティングの味方 #wlstudy
スローダウン、ハングを一発解決 スレッドダンプはトラブルシューティングの味方 #wlstudy
Yusuke Yamamoto
 

What's hot (20)

Inside the JVM - Follow the white rabbit!
Inside the JVM - Follow the white rabbit!Inside the JVM - Follow the white rabbit!
Inside the JVM - Follow the white rabbit!
 
Objective-C Blocks and Grand Central Dispatch
Objective-C Blocks and Grand Central DispatchObjective-C Blocks and Grand Central Dispatch
Objective-C Blocks and Grand Central Dispatch
 
Making Java Groovy (JavaOne 2013)
Making Java Groovy (JavaOne 2013)Making Java Groovy (JavaOne 2013)
Making Java Groovy (JavaOne 2013)
 
Wait for your fortune without Blocking!
Wait for your fortune without Blocking!Wait for your fortune without Blocking!
Wait for your fortune without Blocking!
 
Kotlin is charming; The reasons Java engineers should start Kotlin.
Kotlin is charming; The reasons Java engineers should start Kotlin.Kotlin is charming; The reasons Java engineers should start Kotlin.
Kotlin is charming; The reasons Java engineers should start Kotlin.
 
Java9を迎えた今こそ!Java本格(再)入門
Java9を迎えた今こそ!Java本格(再)入門Java9を迎えた今こそ!Java本格(再)入門
Java9を迎えた今こそ!Java本格(再)入門
 
Inside the JVM - Follow the white rabbit! / Breizh JUG
Inside the JVM - Follow the white rabbit! / Breizh JUGInside the JVM - Follow the white rabbit! / Breizh JUG
Inside the JVM - Follow the white rabbit! / Breizh JUG
 
JRuby @ Boulder Ruby
JRuby @ Boulder RubyJRuby @ Boulder Ruby
JRuby @ Boulder Ruby
 
Java Performance Tuning
Java Performance TuningJava Performance Tuning
Java Performance Tuning
 
Jenkins 2を使った究極のpipeline ~ 明日もう一度来てください、本物のpipelineをお見せしますよ ~
Jenkins 2を使った究極のpipeline ~ 明日もう一度来てください、本物のpipelineをお見せしますよ ~Jenkins 2を使った究極のpipeline ~ 明日もう一度来てください、本物のpipelineをお見せしますよ ~
Jenkins 2を使った究極のpipeline ~ 明日もう一度来てください、本物のpipelineをお見せしますよ ~
 
JavaOne 2011 - JVM Bytecode for Dummies
JavaOne 2011 - JVM Bytecode for DummiesJavaOne 2011 - JVM Bytecode for Dummies
JavaOne 2011 - JVM Bytecode for Dummies
 
スローダウン、ハングを一発解決 スレッドダンプはトラブルシューティングの味方 #wlstudy
スローダウン、ハングを一発解決 スレッドダンプはトラブルシューティングの味方 #wlstudyスローダウン、ハングを一発解決 スレッドダンプはトラブルシューティングの味方 #wlstudy
スローダウン、ハングを一発解決 スレッドダンプはトラブルシューティングの味方 #wlstudy
 
Metaprogramming with Groovy
Metaprogramming with GroovyMetaprogramming with Groovy
Metaprogramming with Groovy
 
What I Love About Ruby
What I Love About RubyWhat I Love About Ruby
What I Love About Ruby
 
Fun with Functional Programming in Clojure
Fun with Functional Programming in ClojureFun with Functional Programming in Clojure
Fun with Functional Programming in Clojure
 
2007 09 10 Fzi Training Groovy Grails V Ws
2007 09 10 Fzi Training Groovy Grails V Ws2007 09 10 Fzi Training Groovy Grails V Ws
2007 09 10 Fzi Training Groovy Grails V Ws
 
Fast as C: How to Write Really Terrible Java
Fast as C: How to Write Really Terrible JavaFast as C: How to Write Really Terrible Java
Fast as C: How to Write Really Terrible Java
 
Connecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyConnecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRuby
 
Beyond JVM - YOW! Sydney 2013
Beyond JVM - YOW! Sydney 2013Beyond JVM - YOW! Sydney 2013
Beyond JVM - YOW! Sydney 2013
 
Little Helpers for Android Development with Kotlin
Little Helpers for Android Development with KotlinLittle Helpers for Android Development with Kotlin
Little Helpers for Android Development with Kotlin
 

Viewers also liked

J2 Me Mobile Application
J2 Me Mobile ApplicationJ2 Me Mobile Application
J2 Me Mobile Application
Imranahmed_19
 
Recordmanagment
RecordmanagmentRecordmanagment
Recordmanagment
myrajendra
 
Record listener interface
Record listener interfaceRecord listener interface
Record listener interface
myrajendra
 
Interface record comparator
Interface record comparatorInterface record comparator
Interface record comparator
myrajendra
 
Interface record enumeration
Interface record enumerationInterface record enumeration
Interface record enumeration
myrajendra
 
Recordmanagment2
Recordmanagment2Recordmanagment2
Recordmanagment2
myrajendra
 
Interface connection
Interface connectionInterface connection
Interface connection
myrajendra
 
Interface Record filter
Interface Record filterInterface Record filter
Interface Record filter
myrajendra
 

Viewers also liked (20)

Mobile Game and Application with J2ME - Collision Detection
Mobile Gameand Application withJ2ME  - Collision DetectionMobile Gameand Application withJ2ME  - Collision Detection
Mobile Game and Application with J2ME - Collision Detection
 
Android architecture
Android architectureAndroid architecture
Android architecture
 
J2 Me Mobile Application
J2 Me Mobile ApplicationJ2 Me Mobile Application
J2 Me Mobile Application
 
Session2-J2ME development-environment
Session2-J2ME development-environmentSession2-J2ME development-environment
Session2-J2ME development-environment
 
Recordmanagment
RecordmanagmentRecordmanagment
Recordmanagment
 
Record listener interface
Record listener interfaceRecord listener interface
Record listener interface
 
Interface record comparator
Interface record comparatorInterface record comparator
Interface record comparator
 
Interface record enumeration
Interface record enumerationInterface record enumeration
Interface record enumeration
 
M rec enum
M rec enumM rec enum
M rec enum
 
Session 3 J2ME Mobile Information Device Profile(MIDP) API
Session 3 J2ME Mobile Information Device Profile(MIDP)  APISession 3 J2ME Mobile Information Device Profile(MIDP)  API
Session 3 J2ME Mobile Information Device Profile(MIDP) API
 
J2ME
J2MEJ2ME
J2ME
 
Recordmanagment2
Recordmanagment2Recordmanagment2
Recordmanagment2
 
Session1 j2me introduction
Session1  j2me introductionSession1  j2me introduction
Session1 j2me introduction
 
Wr ex2
Wr ex2Wr ex2
Wr ex2
 
Exceptions
ExceptionsExceptions
Exceptions
 
Interface connection
Interface connectionInterface connection
Interface connection
 
High-Level Display: Screen J2ME User Interface
High-Level Display: Screen J2ME User InterfaceHigh-Level Display: Screen J2ME User Interface
High-Level Display: Screen J2ME User Interface
 
Session4 J2ME Mobile Information Device Profile(MIDP) Events
Session4 J2ME Mobile Information Device Profile(MIDP) EventsSession4 J2ME Mobile Information Device Profile(MIDP) Events
Session4 J2ME Mobile Information Device Profile(MIDP) Events
 
Interface Record filter
Interface Record filterInterface Record filter
Interface Record filter
 
Record store
Record storeRecord store
Record store
 

Similar to Java 7 Language Enhancement

Java Intro
Java IntroJava Intro
Java Intro
backdoor
 
Boosting Your Testing Productivity with Groovy
Boosting Your Testing Productivity with GroovyBoosting Your Testing Productivity with Groovy
Boosting Your Testing Productivity with Groovy
James Williams
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
David Padbury
 
Persisting Your Objects In The Database World @ AlphaCSP Professional OSS Con...
Persisting Your Objects In The Database World @ AlphaCSP Professional OSS Con...Persisting Your Objects In The Database World @ AlphaCSP Professional OSS Con...
Persisting Your Objects In The Database World @ AlphaCSP Professional OSS Con...
Baruch Sadogursky
 
GTAC Boosting your Testing Productivity with Groovy
GTAC Boosting your Testing Productivity with GroovyGTAC Boosting your Testing Productivity with Groovy
GTAC Boosting your Testing Productivity with Groovy
Andres Almiray
 

Similar to Java 7 Language Enhancement (20)

Project Coin
Project CoinProject Coin
Project Coin
 
Java 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevJava 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from Oredev
 
Java Intro
Java IntroJava Intro
Java Intro
 
New Features Of JDK 7
New Features Of JDK 7New Features Of JDK 7
New Features Of JDK 7
 
Mastering Java ByteCode
Mastering Java ByteCodeMastering Java ByteCode
Mastering Java ByteCode
 
Boosting Your Testing Productivity with Groovy
Boosting Your Testing Productivity with GroovyBoosting Your Testing Productivity with Groovy
Boosting Your Testing Productivity with Groovy
 
Javaone2008 Bof 5101 Groovytesting
Javaone2008 Bof 5101 GroovytestingJavaone2008 Bof 5101 Groovytesting
Javaone2008 Bof 5101 Groovytesting
 
Java 7 new features
Java 7 new featuresJava 7 new features
Java 7 new features
 
Java 7 & 8 New Features
Java 7 & 8 New FeaturesJava 7 & 8 New Features
Java 7 & 8 New Features
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
 
Java 14 features
Java 14 featuresJava 14 features
Java 14 features
 
Sqladria 2009 SRC
Sqladria 2009 SRCSqladria 2009 SRC
Sqladria 2009 SRC
 
Persisting Your Objects In The Database World @ AlphaCSP Professional OSS Con...
Persisting Your Objects In The Database World @ AlphaCSP Professional OSS Con...Persisting Your Objects In The Database World @ AlphaCSP Professional OSS Con...
Persisting Your Objects In The Database World @ AlphaCSP Professional OSS Con...
 
JS everywhere 2011
JS everywhere 2011JS everywhere 2011
JS everywhere 2011
 
GTAC Boosting your Testing Productivity with Groovy
GTAC Boosting your Testing Productivity with GroovyGTAC Boosting your Testing Productivity with Groovy
GTAC Boosting your Testing Productivity with Groovy
 
jrubykaigi2010-lt-rubeus
jrubykaigi2010-lt-rubeusjrubykaigi2010-lt-rubeus
jrubykaigi2010-lt-rubeus
 
Introduction To Groovy 2005
Introduction To Groovy 2005Introduction To Groovy 2005
Introduction To Groovy 2005
 
모던자바의 역습
모던자바의 역습모던자바의 역습
모던자바의 역습
 
roofimon@njug5
roofimon@njug5roofimon@njug5
roofimon@njug5
 

More from muthusvm (11)

Session13 J2ME Timer
Session13  J2ME TimerSession13  J2ME Timer
Session13 J2ME Timer
 
Session12 J2ME Generic Connection Framework
Session12 J2ME Generic Connection FrameworkSession12 J2ME Generic Connection Framework
Session12 J2ME Generic Connection Framework
 
Session11 J2ME Record Management System Database
Session11 J2ME Record Management System DatabaseSession11 J2ME Record Management System Database
Session11 J2ME Record Management System Database
 
Session11 J2ME MID-Low Level User Interface(LLUI)-graphics
Session11 J2ME MID-Low Level User Interface(LLUI)-graphicsSession11 J2ME MID-Low Level User Interface(LLUI)-graphics
Session11 J2ME MID-Low Level User Interface(LLUI)-graphics
 
Session11 J2ME Record Management System
Session11 J2ME Record Management SystemSession11 J2ME Record Management System
Session11 J2ME Record Management System
 
Session10 J2ME Record Management System
Session10 J2ME Record Management SystemSession10 J2ME Record Management System
Session10 J2ME Record Management System
 
Session9 J2ME Record Management System
Session9 J2ME Record Management SystemSession9 J2ME Record Management System
Session9 J2ME Record Management System
 
Session8 J2ME Low Level User Interface
Session8 J2ME Low Level User InterfaceSession8 J2ME Low Level User Interface
Session8 J2ME Low Level User Interface
 
Session7 J2ME High Level User Interface(HLUI) part1-2
Session7 J2ME High Level User Interface(HLUI) part1-2Session7 J2ME High Level User Interface(HLUI) part1-2
Session7 J2ME High Level User Interface(HLUI) part1-2
 
Session6 J2ME High Level User Interface(HLUI) part1
Session6 J2ME High Level User Interface(HLUI) part1Session6 J2ME High Level User Interface(HLUI) part1
Session6 J2ME High Level User Interface(HLUI) part1
 
Session5 J2ME High Level User Interface(HLUI) part1
Session5 J2ME High Level User Interface(HLUI) part1Session5 J2ME High Level User Interface(HLUI) part1
Session5 J2ME High Level User Interface(HLUI) part1
 

Recently uploaded

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Recently uploaded (20)

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 

Java 7 Language Enhancement

  • 1.   Tossing the Project Coin!   Marimuthu Rajagopal
  • 2.
  • 3.
  • 4.
  • 5. String in Switch Java 6 and Prior public static String getTypeOfDayWithSwitchStatement(String dayOfWeekArg) { String typeOfDay=&quot;&quot;; if(dayOfWeekArg.equals(&quot;Monday&quot;)) typeOfDay=&quot;Start of Work week&quot;; else if(dayOfWeekArg.equals(&quot;Tuesday&quot;)|| dayOfWeekArg.equals(&quot;Wednesday&quot;)|| dayOfWeekArg.equals(&quot;Thursday&quot;)) typeOfDay=&quot;Midweek&quot;; else if(dayOfWeekArg.equals(&quot;Friday&quot;)) typeOfDay=&quot;End of work week&quot;; else if(dayOfWeekArg.equals(&quot;Saturday&quot;)|| dayOfWeekArg.equals(&quot;Sunday&quot;)) typeOfDay=&quot;Week off&quot;; else typeOfDay=&quot;Invalid day&quot;; return typeOfDay; } http://download.java.net/jdk7/docs/technotes/guides/language/strings-switch.html
  • 6. String in Switch Java 7 public static String getTypeOfDayWithSwitchStatement(String dayOfWeekArg) { String typeOfDay=&quot;&quot;; switch (dayOfWeekArg) { case &quot;Monday&quot;: typeOfDay=&quot;Start of Work week&quot;; break; case &quot;Tuesday&quot;: case &quot;Wednesday&quot;: case &quot;Thursday&quot;: typeOfDay=&quot;Midweek&quot;; break; case &quot;Friday&quot;: typeOfDay=&quot;End of work week&quot;; break; case &quot;Saturday&quot;: case &quot;Sunday&quot;: typeOfDay=&quot;Week off&quot;; break; default: typeOfDay=&quot;Invalid day&quot;; break; } return typeOfDay; } http://download.java.net/jdk7/docs/technotes/guides/language/strings-switch.html
  • 7.
  • 8.
  • 9.
  • 10. Multi-Catch. Java 6 and Prior try{ // Method method=Object.class.getMethod(&quot;toString&quot;); final Class[] ARG_TYPE=new Class[]{String.class}; Method method=Integer.class.getMethod(&quot;parseInt&quot;,ARG_TYPE); Object result=method.invoke(null,new Object[]{new String(&quot;44&quot;)}); System.out.println(&quot;result:&quot;+result.toString()); } catch(NoSuchMethodException e) { e.printStackTrace(); }catch(IllegalAccessException e) { e.printStackTrace(); } catch(InvocationTargetException e) { e.printStackTrace(); }
  • 11. Multi-Catch. Java 7 try{ // Method method=Object.class.getMethod(&quot;toString&quot;); final Class[] ARG_TYPE=new Class[]{String.class}; Method method=Integer.class.getMethod(&quot;parseInt&quot;,ARG_TYPE); Object result=method.invoke(null,new Object[]{new String(&quot;44&quot;)}); System.out.println(&quot;result:&quot;+result.toString()); } catch( NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { e.printStackTrace(); }
  • 12. More precise rethrow. Java 6 and Prior public static void precise() throws NoSuchMethodException, IllegalAccessException { try{ // Method method=Object.class.getMethod(&quot;toString&quot;); final Class[] ARG_TYPE=new Class[]{String.class}; Method method=Integer.class.getMethod(&quot;parseInt&quot;,ARG_TYPE); Object result=method.invoke(null,new Object[]{new String(&quot;44&quot;)}); System.out.println(&quot;result:&quot;+result.toString()); } catch(Exception e) { throw new NoSuchMethodException(); } }
  • 13. More precise rethrow. Java 7 public static void precise() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { try{ // Method method=Object.class.getMethod(&quot;toString&quot;); final Class[] ARG_TYPE=new Class[]{String.class}; Method method=Integer.class.getMethod(&quot;parseInt&quot;,ARG_TYPE); Object result=method.invoke(null,new Object[]{new String(&quot;44&quot;)}); System.out.println(&quot;result:&quot;+result.toString()); } catch(ReflectiveOperationException e) { throw e; } }
  • 14.
  • 15. Try-with-Resources statement. Java 6 and Prior static void jdk16writeFile(String path) { BufferedWriter bw = null; try { bw=new BufferedWriter(new FileWriter(path)); bw.write(&quot;JDK1.6 Need to close resource manualy.&quot;); }catch(IOException e) { e.printStackTrace(); } finally { try { bw.close(); } catch (IOException ex) { ex.printStackTrace(); } } }
  • 16. Try-with-Resources statement. Java 7 static void jdk17writeFile(String path) { try (BufferedWriter bw = new BufferedWriter(new FileWriter(path))) { bw.write(&quot;Welcome to JDK1.7 Try with resource concept&quot;); } catch(IOException ex) ‏ { System.out.println(&quot;ex&quot;+ex); } }
  • 17.
  • 18. Diamond Operator(Type Inference for Generic Instance Creation) ‏ In Java 6 and Prior List<String> jvmLanguages=new ArrayList<String>(); In Java 7 List<String> jvmLanguages=new ArrayList<>(); jvmLanguages.add(&quot;Groovy&quot;); jvmLanguages.add(&quot;Scala&quot;); System.out.println(jvmLanguages); Type Inference List<?> typeinference=new ArrayList<> ();
  • 19.
  • 20. Thank you Q&A    e-mail :muthu.svm@gmail.com blog :http://microtechinfo.blogspot.com