Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)

1,652 views

Published on

Kelby Zorgdrager from DevelopIntelligence explains the differences between the variations of Java and what's new in Java 7.

If you need help with Java training DevelopIntelligence and provide on-site training within two weeks. Customized and affordable for any organization.

Published in: Technology, Education
  • Be the first to comment

  • Be the first to like this

Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)

  1. 1. What’s New in Java 5, 6 & 7 Delivered by DevelopIntelligence
  2. 2. About DevelopIntelligence Provide highly-customized, role-based, project- centric learning solutions to software teams Specialize in areas of Java, Open Source, Web Development, and Mobile Delivered training to over 40,000 engineers worldwide Headquartered in Boulder CO
  3. 3. About Kelby Zorgdrager President of DevelopIntelligence Working with and teaching Java since 1996 (1.0.1) Former Sun Microsystems Java Platform engineer Delivered training to over 5,000 engineers worldwide Copyright DevelopIntelligence LLC
  4. 4. Webinar Topics In this presentation, we will cover: Current State of Java Newish Language Features Questions at the end DevelopIntelligence http://www.DevelopIntelligence.com 4
  5. 5. Objectives When we are done, you should be: Familiar with current state of Java Aware of new features DevelopIntelligence http://www.DevelopIntelligence.com 5
  6. 6. Current State of Java Copyright DevelopIntelligence LLC
  7. 7. Java SE 5.0 Significant revamp of Java Not largest revamp in terms of new APIs Significance lies in new language features Released Sept 2004 - Code named “Tiger” EOL’d Oct 30, 2009 Current version 1.5 update 22 DevelopIntelligence http://www.DevelopIntelligence.com 7
  8. 8. Java SE 6 Focused on refreshing APIs, internals, and Scripting support Released Dec 2006 - Code named “Mustag” Current version 1.6 update 43 DevelopIntelligence http://www.DevelopIntelligence.com 8
  9. 9. Java SE 7 Focused on simplifying language, APIs, internals, and dynamic language support Released July 2011 - Code named “Dolphin” Current version 1.7 update 21 DevelopIntelligence http://www.DevelopIntelligence.com 9
  10. 10. Breadth of Java Across Versions 10DevelopIntelligence http://www.DevelopIntelligence.com 8 22 59 76 135 166 203 209202 477 1524 1840 2723 3279 3793 4024 0 500 1000 1500 2000 2500 3000 3500 4000 4500 1.0.2 1.1 1.2 1.3 1.4 1.5 1.6 1.7 Amount Java Version Growth of Java Packages Classes
  11. 11. Growth of Java Across Versions 11DevelopIntelligence http://www.DevelopIntelligence.com 0 275 268 129 178 123 122 103 0 236 319 121 148 120 116 106 0 50 100 150 200 250 300 350 1.0.2 1.1 1.2 1.3 1.4 1.5 1.6 1.7 PercentageGrowth Version Growth of Java Package Growth Class Growth
  12. 12. Language Features “newish” Copyright DevelopIntelligence LLC
  13. 13. General Language Niceties Copyright DevelopIntelligence LLC
  14. 14. Single Static Import [1.5] 14DevelopIntelligence http://www.DevelopIntelligence.com provide direct access to static variables and methods
  15. 15. On-Demand Static Import [1.5] 15DevelopIntelligence http://www.DevelopIntelligence.com
  16. 16. Literals [1.7] Copyright DevelopIntelligence LLC
  17. 17. Simplification of Strings [1.7] Strings are constants - And - treated like primitives (at least from a coding perspective) But until Java 7 – weren’t supported in switch statements Copyright DevelopIntelligence LLC String a = “Hello”; . . . switch(a) { case “hello”: case “Hello”: case “HELLO” //do something break; default: //do something else break; }
  18. 18. Autoboxing [1.5] 18DevelopIntelligence http://www.DevelopIntelligence.com
  19. 19. Collection Autoboxing [1.5] 19DevelopIntelligence http://www.DevelopIntelligence.com
  20. 20. Autoboxing Support Primitive Type Reference Type boolean java.lang.Boolean byte java.lang.Byte short java.lang.Short int java.lang.Integer long java.lang.Long float java.lang.Float double java.lang.Double char java.lang.Character 20DevelopIntelligence http://www.DevelopIntelligence.com
  21. 21. For-each Loop [1.5] 21DevelopIntelligence http://www.DevelopIntelligence.com
  22. 22. Iterable For-each Loop [1.5] 22DevelopIntelligence http://www.DevelopIntelligence.com
  23. 23. Variable Method Arguments [old way] 23DevelopIntelligence http://www.DevelopIntelligence.com
  24. 24. varargs [1.5] 24DevelopIntelligence http://www.DevelopIntelligence.com
  25. 25. enums Copyright DevelopIntelligence LLC
  26. 26. Working with an Enum Enums are types – provide type safety for a closed set of values Values are instances of an enum type Stored as static final fields in type Defined in terms of name - stringified representation of field name ordinal - position in set Referencable through dot-notation Are switchable 26DevelopIntelligence http://www.DevelopIntelligence.com
  27. 27. enum [1.5] 27DevelopIntelligence http://www.DevelopIntelligence.com
  28. 28. Working with an Enum [cont.] Reference using dot notation Enums have some predefined static methods values – retrieves all enum instances valueOf - transforms String value into enum instance Have some predefined instance methods name – upper-case name of enum instance toString equals hashCode 28DevelopIntelligence http://www.DevelopIntelligence.com
  29. 29. Accessing an Enum Value 29DevelopIntelligence http://www.DevelopIntelligence.com
  30. 30. Enum Switch Example 30DevelopIntelligence http://www.DevelopIntelligence.com
  31. 31. Enum Method Example 31DevelopIntelligence http://www.DevelopIntelligence.com Prints: SUNDAY MONDAY TUESDAY WEDNESDAY THURSDAY FRIDAY SATURDAY
  32. 32. Typesafe Collections Copyright DevelopIntelligence LLC
  33. 33. Typesafe Collection Advantages Adds compile time type safety to collections Type safety simplifies collection interactions (ie: iterating) No advantages (or disadvantages) in speed or performance 33DevelopIntelligence http://www.DevelopIntelligence.com
  34. 34. Simple List Example [Old way] 34DevelopIntelligence http://www.DevelopIntelligence.com
  35. 35. Simple List Example [1.5] 35DevelopIntelligence http://www.DevelopIntelligence.com
  36. 36. Simplification of Generics [1.7] 1.5 way of declaring and initializing a collection: List<String> list = new ArrayList<String>(); Compiler should be “smart enough” to infer type from declaration 1.7 way of declaring and initializing: List<String> list = new ArrayList<>(); Copyright DevelopIntelligence LLC
  37. 37. Annotations Copyright DevelopIntelligence LLC
  38. 38. Annotations Metadata facility for Java Allowing you to provide additional data alongside Java classes Similar to Javadoc “metadata” facility Expanded and formalized mechanism “Competes” with Doclet / XDoclet Recognized by Java compiler and other tools DevelopIntelligence http://www.DevelopIntelligence.com 38
  39. 39. @Override Example [1.5] 39DevelopIntelligence http://www.DevelopIntelligence.com
  40. 40. Covariant Returns Copyright DevelopIntelligence LLC
  41. 41. Covariant Returns What are they? Allows return type of inherited method to be narrowed Applies to method over-riding not over-loading Why do they exist? Needed to support generics mechanism Removes narrowing cast on polymorphic returns Prevents run-time ClassCastExceptions on returns Provides compile-time type dependency checking 41DevelopIntelligence http://www.DevelopIntelligence.com
  42. 42. Covariant Return Example [1.5] DevelopIntelligence http://www.DevelopIntelligence.com 42
  43. 43. 43 Auto-Closing Resources DevelopIntelligence http://www.DevelopIntelligence.com
  44. 44. Simplification of try/catch [1.7] There’s a lot of try/catch/finally boiler-plate code out there Why not let the compiler generate it for you? Copyright DevelopIntelligence LLC FileInputStream fis; try { fis = new FileInputStream(“/tmp/myfile.txt”); … } catch(IOException ioe) { … } finally { fis.close() } try (InputStream fis =new FileInputStream(“/tmp/myfile.txt”)) { … } New way
  45. 45. Simplification of try/catch [1.7] Do we really need all those catches? Copyright DevelopIntelligence LLC
  46. 46. How DevelopIntelligence Can Help? FAST: We can provide customized on-site training within two weeks to help with tight deadlines. CUSTOMIZED: Complete customization of the training you need at no additional costs to your organization. AFFORDABLE: We have the most flexible pricing module in the industry and can work with any budget. CONTACT US: 877-629-5631 dave@developintelligence.com kelby@developintelligence.com DevelopIntelligence http://www.DevelopIntelligence.com 46
  47. 47. Win a Free Safari Account Question: “What date did the FCS of JDK 1.0 occur” Post your answer to: LinkedIn: http://www.linkedin.com/company/developintelligence Twitter: http://twitter.com/DevIntelligence All correct answers will be entered into a raffle – winners will be announced Monday June 17 Copyright DevelopIntelligence LLC

×