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.

New features in java se 8


Published on

New features in java se 8

Published in: Software
  • Be the first to comment

  • Be the first to like this

New features in java se 8

  1. 1. External Use TM New Features in Java SE 8 N O V E M B E R . 2 5 . 2 0 1 5 Melania Mitisor
  2. 2. TM External Use 1 New Features in Java® SE 8 • Lambda expressions • Default or Extension Methods • Static Methods in Interfaces • Functional Interface • Method references • Annotations on Java Types • Access to Parameter Names at Runtime
  3. 3. TM External Use 2 Lambda Expressions • Lambda expressions provide anonymous function types to Java. − It’s a method without a declaration, i.e., access modifier, return value declaration, and name. − It allows you to write a method in the same place you are going to use it. It is useful in places where a method is being used only once, and the method definition is short. It saves you the effort of declaring and writing a separate method to the containing class.
  4. 4. TM External Use 3 Static Methods in Interfaces • Starting with Java 8 it is possible to include static methods in an interface • Static methods can’t be overridden in the implementation classes.
  5. 5. TM External Use 4 Default or Extension Methods • Provide a mechanism to add new methods to existing interfaces − Without breaking backward compatibility − JDK itself is utilizing default methods. java.util.Map interface is extended with several new default methods e.g. replaceAll(), putIfAbsent(Key k, Value v) and others. − Default methods are similar to the static methods, but they can be overridden in implementation classes.
  6. 6. TM External Use 5 Functional Interface • Single Abstract Method (SAM) type • A functional interface is an interface that has one abstract method − It can have more than one method • @FunctionalInterface annotation had been added − Helps ensure the functional interface contract is honored − Compile error if not a SAM
  7. 7. TM External Use 6 Method references • Method references let us reuse a method as a lambda expression
  8. 8. TM External Use 7 Annotations on Java Types • Annotations can currently only be used on type declarations − Classes, methods, variable definitions • Extensions for places where types are used: − E.g. parameters • Permits error detection by pluggable type checkers − E.g. null pointer errors, race conditions, etc
  9. 9. TM External Use 8 Access to Parameter Names at Runtime • Mechanism to retrieve parameter names of methods and constructors − At runtime via core reflection • Improve code readability − Eliminate redundant annotations • Improve IDE capabilities − Auto-generate template code • Method and Constructor now inherit from new Executable class − getParameters() returns array of Parameter objects − Name, type, annotations for each parameter
  10. 10. TM External Use 9 References • • 2100321.html • 2157071.html • tutorial.html • 55-new-features-java-se-8-2202551-zhs.pdf
  11. 11. TM © 2015 Freescale Semiconductor, Inc. | External Use