Java SE 8 New Features
Aymen MASRI @Atos
6th August, 2018
Take a tour of the new features in Java SE 8, the platform designed to support faster and easier Java development. A new
syntax to support lambda expressions in Java code; the new Stream API for processing collections and managing parallel
processing; the DateTime API for representing, managing and calculating date and time values; and Nashorn, a new
engine to better support the use of JavaScript code with the Java Virtual Machine.
Table of Contents
2 | Java SE 8 New Features
1
4
3
5 Miscellaneous New Features
2 Processing Collections with Streams
Lambda Expressions and Method Enhancements
New Date and Time API
JavaScript with the Java Virtual Machine
Lambda Expressions and
Method Enhancements
Lambda Expressions and Method Enhancements
4 | Java SE 8 New Features
Lambda Expression
• Lambda expression are anonymous functions
• Instantiate interfaces with a single method
• Replace more verbose class declarations
Where to Use Lambda Expressions
Lambda expressions can only appear in places where they be assigned to a variable
whose type is a functional interface.
Lambda Expressions and Method Enhancements
5 | Java SE 8 New Features
Functional Interfaces
• A functional interface has a single abstract method
• Functional interfaces included with Java runtime
Runnable, Callable, Comparator, TimerTask
•Prior to Java SE 8
Know as "Simple Abstract Method" (SAM) Types
Lambda Expressions and Method Enhancements
6 | Java SE 8 New Features
Lambda Expression Syntax
Runnable r = () -> System.out.println("Hello!");
Methode
signature
Methode
Implementation
Lambda Expressions and Method Enhancements
7 | Java SE 8 New Features
Sample code (https://github.com/aymenmasri/Java_SE_8_NF/tree/master/01_Lambdas)
• Defining and instantiating a functional interface (FunctionalInterface project)
• Using built-in functional interfaces with lambdas (BuiltInInterfaces project)
• Traversing collections with lambda expressions (TraverseCollection project)
• Filtering collections with predicate interfaces (FilterCollection project)
• Traversing collections with method references (MethodReferences project)
• Implementing default methods in interfaces (DefaultMethods project)
• Implementing static methods in interfaces (StaticMethods project)
Lambda Expressions and Method Enhancements
8 | Java SE 8 New Features
Defining and instantiating a functional interface
Source code
https://github.com/aymenmasri/Java_SE_8_NF/tree/master/01_Lamb
das/FunctionalInterface
Lambda Expressions and Method Enhancements
9 | Java SE 8 New Features
Using built-in functional interfaces with lambdas
Source code
https://github.com/aymenmasri/Java_SE_8_NF/tree/master/01_Lamb
das/BuiltInInterfaces
Lambda Expressions and Method Enhancements
10 | Java SE 8 New Features
Traversing collections with lambda expressions
Source code
https://github.com/aymenmasri/Java_SE_8_NF/tree/master/01_Lamb
das/TraverseCollection
Lambda Expressions and Method Enhancements
11 | Java SE 8 New Features
Filtering collections with predicate interfaces
Source code
https://github.com/aymenmasri/Java_SE_8_NF/tree/master/01_Lamb
das/FilterCollection
Lambda Expressions and Method Enhancements
12 | Java SE 8 New Features
Traversing collections with method references
Source code
https://github.com/aymenmasri/Java_SE_8_NF/tree/master/01_Lamb
das/MethodReferences
Lambda Expressions and Method Enhancements
13 | Java SE 8 New Features
Implementing default methods in interfaces
Source code
https://github.com/aymenmasri/Java_SE_8_NF/tree/master/01_Lamb
das/DefaultMethods
Lambda Expressions and Method Enhancements
14 | Java SE 8 New Features
Implementing static methods in interfaces
Source code
https://github.com/aymenmasri/Java_SE_8_NF/tree/master/01_Lamb
das/StaticMethods
Processing Collections
with Streams
Processing Collections with Streams
16 | Java SE 8 New Features
Sample code (https://github.com/aymenmasri/Java_SE_8_NF/tree/master/02_Streams)
• Traversing collections with streams (TraversingStreams project)
• Creating streams from collections and arrays (CreatingStreams project)
• Aggregating stream values (AggregatingStreams project)
Processing Collections with Streams
17 | Java SE 8 New Features
Traversing collections with streams
Source code
https://github.com/aymenmasri/Java_SE_8_NF/tree/master/02_Strea
ms/TraversingStreams
Processing Collections with Streams
18 | Java SE 8 New Features
Creating streams from collections and arrays
Source code
https://github.com/aymenmasri/Java_SE_8_NF/tree/master/02_Strea
ms/CreatingStreams
Processing Collections with Streams
19 | Java SE 8 New Features
Aggregating stream values
Source code
https://github.com/aymenmasri/Java_SE_8_NF/tree/master/02_Strea
ms/AggregatingStreams
New Date and Time API
New Date and Time API
21 | Java SE 8 New Features
Sample code (https://github.com/aymenmasri/Java_SE_8_NF/tree/master/03_DateTime)
• Calculating time spans with Instant and Duration (InstantAndDuration project)
• Representing date and time values (DatesAndTimes project)
• Formatting date and time values (FormatDateTime project)
• Supporting time-zone offsets (TimeZones project)
New Date and Time API
22 | Java SE 8 New Features
Calculating time spans with Instant and Duration
Source code
https://github.com/aymenmasri/Java_SE_8_NF/tree/master/02_Strea
ms/InstantAndDuration
New Date and Time API
23 | Java SE 8 New Features
Representing date and time values
Source code
https://github.com/aymenmasri/Java_SE_8_NF/tree/master/02_Strea
ms/DatesAndTimes
New Date and Time API
24 | Java SE 8 New Features
Formatting date and time values
Source code
https://github.com/aymenmasri/Java_SE_8_NF/tree/master/02_Strea
ms/FormatDateTime
New Date and Time API
25 | Java SE 8 New Features
Supporting time-zone offsets
Source code
https://github.com/aymenmasri/Java_SE_8_NF/tree/master/02_Strea
ms/TimeZones
JavaScript with the Java
Virtual Machine
JavaScript with the Java Virtual Machine
27 | Java SE 8 New Features
Sample code (https://github.com/aymenmasri/Java_SE_8_NF/tree/master/04_Nashorn)
• Running JavaScript from Java (JSFromJava project)
• Writing JavaScript for Nashorn (JSFromFile project)
JavaScript with the Java Virtual Machine
28 | Java SE 8 New Features
Running JavaScript from Java
Source code
https://github.com/aymenmasri/Java_SE_8_NF/tree/master/04_Nash
orn/JSFromJava
JavaScript with the Java Virtual Machine
29 | Java SE 8 New Features
Writing JavaScript for Nashorn
Source code
https://github.com/aymenmasri/Java_SE_8_NF/tree/master/04_Nash
orn/JSFromFile
Miscellaneous New
Features
Miscellaneous New Features
31 | Java SE 8 New Features
Sample code (https://github.com/aymenmasri/Java_SE_8_NF/tree/master/05_Miscellaneous)
• Joining string values into delimited lists (JoiningStrings project)
• Searching text files with streams (SearchFile project)
Miscellaneous New Features
32 | Java SE 8 New Features
Joining string values into delimited lists
Source code
https://github.com/aymenmasri/Java_SE_8_NF/tree/master/04_Nash
orn/JSFromFile
Miscellaneous New Features
33 | Java SE 8 New Features
Searching text files with streams
Source code
https://github.com/aymenmasri/Java_SE_8_NF/tree/master/04_Nash
orn/SearchFile
Miscellaneous New Features
34 | Java SE 8 New Features
Other new features in Java SE 8
• Enhancements in concurrency
• JDBC 4.2
More details
http://www.oracle.com/technetwork/java/javase/8-whats-new-2157071.html
Atos, the Atos logo, Atos Codex, Atos Consulting, Atos Worldgrid, Worldline, BlueKiwi, Bull, Canopy the
Open Cloud Company, Unify, Yunano, Zero Email, Zero Email Certified and The Zero Email Company are
registered trademarks of the Atos group. April 2016. © 2016 Atos. Confidential information owned by
Atos, to be used by the recipient only. This document, or any part of it, may not be reproduced, copied,
circulated and/or distributed nor quoted without prior written approval from Atos.
Thanks

Java se 8 new features

  • 1.
    Java SE 8New Features Aymen MASRI @Atos 6th August, 2018 Take a tour of the new features in Java SE 8, the platform designed to support faster and easier Java development. A new syntax to support lambda expressions in Java code; the new Stream API for processing collections and managing parallel processing; the DateTime API for representing, managing and calculating date and time values; and Nashorn, a new engine to better support the use of JavaScript code with the Java Virtual Machine.
  • 2.
    Table of Contents 2| Java SE 8 New Features 1 4 3 5 Miscellaneous New Features 2 Processing Collections with Streams Lambda Expressions and Method Enhancements New Date and Time API JavaScript with the Java Virtual Machine
  • 3.
  • 4.
    Lambda Expressions andMethod Enhancements 4 | Java SE 8 New Features Lambda Expression • Lambda expression are anonymous functions • Instantiate interfaces with a single method • Replace more verbose class declarations Where to Use Lambda Expressions Lambda expressions can only appear in places where they be assigned to a variable whose type is a functional interface.
  • 5.
    Lambda Expressions andMethod Enhancements 5 | Java SE 8 New Features Functional Interfaces • A functional interface has a single abstract method • Functional interfaces included with Java runtime Runnable, Callable, Comparator, TimerTask •Prior to Java SE 8 Know as "Simple Abstract Method" (SAM) Types
  • 6.
    Lambda Expressions andMethod Enhancements 6 | Java SE 8 New Features Lambda Expression Syntax Runnable r = () -> System.out.println("Hello!"); Methode signature Methode Implementation
  • 7.
    Lambda Expressions andMethod Enhancements 7 | Java SE 8 New Features Sample code (https://github.com/aymenmasri/Java_SE_8_NF/tree/master/01_Lambdas) • Defining and instantiating a functional interface (FunctionalInterface project) • Using built-in functional interfaces with lambdas (BuiltInInterfaces project) • Traversing collections with lambda expressions (TraverseCollection project) • Filtering collections with predicate interfaces (FilterCollection project) • Traversing collections with method references (MethodReferences project) • Implementing default methods in interfaces (DefaultMethods project) • Implementing static methods in interfaces (StaticMethods project)
  • 8.
    Lambda Expressions andMethod Enhancements 8 | Java SE 8 New Features Defining and instantiating a functional interface Source code https://github.com/aymenmasri/Java_SE_8_NF/tree/master/01_Lamb das/FunctionalInterface
  • 9.
    Lambda Expressions andMethod Enhancements 9 | Java SE 8 New Features Using built-in functional interfaces with lambdas Source code https://github.com/aymenmasri/Java_SE_8_NF/tree/master/01_Lamb das/BuiltInInterfaces
  • 10.
    Lambda Expressions andMethod Enhancements 10 | Java SE 8 New Features Traversing collections with lambda expressions Source code https://github.com/aymenmasri/Java_SE_8_NF/tree/master/01_Lamb das/TraverseCollection
  • 11.
    Lambda Expressions andMethod Enhancements 11 | Java SE 8 New Features Filtering collections with predicate interfaces Source code https://github.com/aymenmasri/Java_SE_8_NF/tree/master/01_Lamb das/FilterCollection
  • 12.
    Lambda Expressions andMethod Enhancements 12 | Java SE 8 New Features Traversing collections with method references Source code https://github.com/aymenmasri/Java_SE_8_NF/tree/master/01_Lamb das/MethodReferences
  • 13.
    Lambda Expressions andMethod Enhancements 13 | Java SE 8 New Features Implementing default methods in interfaces Source code https://github.com/aymenmasri/Java_SE_8_NF/tree/master/01_Lamb das/DefaultMethods
  • 14.
    Lambda Expressions andMethod Enhancements 14 | Java SE 8 New Features Implementing static methods in interfaces Source code https://github.com/aymenmasri/Java_SE_8_NF/tree/master/01_Lamb das/StaticMethods
  • 15.
  • 16.
    Processing Collections withStreams 16 | Java SE 8 New Features Sample code (https://github.com/aymenmasri/Java_SE_8_NF/tree/master/02_Streams) • Traversing collections with streams (TraversingStreams project) • Creating streams from collections and arrays (CreatingStreams project) • Aggregating stream values (AggregatingStreams project)
  • 17.
    Processing Collections withStreams 17 | Java SE 8 New Features Traversing collections with streams Source code https://github.com/aymenmasri/Java_SE_8_NF/tree/master/02_Strea ms/TraversingStreams
  • 18.
    Processing Collections withStreams 18 | Java SE 8 New Features Creating streams from collections and arrays Source code https://github.com/aymenmasri/Java_SE_8_NF/tree/master/02_Strea ms/CreatingStreams
  • 19.
    Processing Collections withStreams 19 | Java SE 8 New Features Aggregating stream values Source code https://github.com/aymenmasri/Java_SE_8_NF/tree/master/02_Strea ms/AggregatingStreams
  • 20.
    New Date andTime API
  • 21.
    New Date andTime API 21 | Java SE 8 New Features Sample code (https://github.com/aymenmasri/Java_SE_8_NF/tree/master/03_DateTime) • Calculating time spans with Instant and Duration (InstantAndDuration project) • Representing date and time values (DatesAndTimes project) • Formatting date and time values (FormatDateTime project) • Supporting time-zone offsets (TimeZones project)
  • 22.
    New Date andTime API 22 | Java SE 8 New Features Calculating time spans with Instant and Duration Source code https://github.com/aymenmasri/Java_SE_8_NF/tree/master/02_Strea ms/InstantAndDuration
  • 23.
    New Date andTime API 23 | Java SE 8 New Features Representing date and time values Source code https://github.com/aymenmasri/Java_SE_8_NF/tree/master/02_Strea ms/DatesAndTimes
  • 24.
    New Date andTime API 24 | Java SE 8 New Features Formatting date and time values Source code https://github.com/aymenmasri/Java_SE_8_NF/tree/master/02_Strea ms/FormatDateTime
  • 25.
    New Date andTime API 25 | Java SE 8 New Features Supporting time-zone offsets Source code https://github.com/aymenmasri/Java_SE_8_NF/tree/master/02_Strea ms/TimeZones
  • 26.
    JavaScript with theJava Virtual Machine
  • 27.
    JavaScript with theJava Virtual Machine 27 | Java SE 8 New Features Sample code (https://github.com/aymenmasri/Java_SE_8_NF/tree/master/04_Nashorn) • Running JavaScript from Java (JSFromJava project) • Writing JavaScript for Nashorn (JSFromFile project)
  • 28.
    JavaScript with theJava Virtual Machine 28 | Java SE 8 New Features Running JavaScript from Java Source code https://github.com/aymenmasri/Java_SE_8_NF/tree/master/04_Nash orn/JSFromJava
  • 29.
    JavaScript with theJava Virtual Machine 29 | Java SE 8 New Features Writing JavaScript for Nashorn Source code https://github.com/aymenmasri/Java_SE_8_NF/tree/master/04_Nash orn/JSFromFile
  • 30.
  • 31.
    Miscellaneous New Features 31| Java SE 8 New Features Sample code (https://github.com/aymenmasri/Java_SE_8_NF/tree/master/05_Miscellaneous) • Joining string values into delimited lists (JoiningStrings project) • Searching text files with streams (SearchFile project)
  • 32.
    Miscellaneous New Features 32| Java SE 8 New Features Joining string values into delimited lists Source code https://github.com/aymenmasri/Java_SE_8_NF/tree/master/04_Nash orn/JSFromFile
  • 33.
    Miscellaneous New Features 33| Java SE 8 New Features Searching text files with streams Source code https://github.com/aymenmasri/Java_SE_8_NF/tree/master/04_Nash orn/SearchFile
  • 34.
    Miscellaneous New Features 34| Java SE 8 New Features Other new features in Java SE 8 • Enhancements in concurrency • JDBC 4.2 More details http://www.oracle.com/technetwork/java/javase/8-whats-new-2157071.html
  • 36.
    Atos, the Atoslogo, Atos Codex, Atos Consulting, Atos Worldgrid, Worldline, BlueKiwi, Bull, Canopy the Open Cloud Company, Unify, Yunano, Zero Email, Zero Email Certified and The Zero Email Company are registered trademarks of the Atos group. April 2016. © 2016 Atos. Confidential information owned by Atos, to be used by the recipient only. This document, or any part of it, may not be reproduced, copied, circulated and/or distributed nor quoted without prior written approval from Atos. Thanks