SlideShare a Scribd company logo
1 of 32
© 2013 KMS Technology
JAVA 8 FEATURES
TRUNG NGUYEN
TECHCON 2014
KMS TECHNOLOGY VIETNAM
JAVA VERSION HISTORY
JDK 1.0 (1996) JDK 1.1 (1997)
inner classes
JavaBeans, JDBC, RMI,
reflection, JIT
JDK 1.2 (1998)
strictfp keyword
Swing API,
Collections API
J2SE 1.3 (2000)
JNDI, JPDA
JAVA 8 FEATURES
J2SE 1.4 (2002)
assert keyword
Image IO API, Java Web
Start
J2SE 5.0 (2004)
generics, annotations,
enum, varagrs
Java SE 6 (2006)
Performance
improvements
Scripting Language, Java
Compiler API
Java SE 7 (2011)
try statement,
invokedynamic in JVM
String in switch,
diamond operation
JAVA 8 RELEASE (MAR 18, 2014)
Java 7
Lambda Expressions
Default Methods
Stream API
New Date/Time APINashorn
Java 8
JAVA 8 FEATURES
Others
LAMBDA EXPRESSIONS
Java 7
Lambda Expressions
Default Methods
Stream API
New Date/Time APINashorn
Java 8
Others
JAVA 8 FEATURES
LAMBDA EXPRESSION
JAVA 8 FEATURES
Functions in Functional Programming
Functions in Java
 Are arguments, return values from other functions
 Are variables and be able stored in data structures
 No new types such as function types
 Functional Interfaces: are interfaces with exactly one method
 java.util.function package
Consumer, Function, Predicate, Supplier, BiFunction, DoubleConsumer,
IntPredicate, LongSupplier, …
Lambda Expressions are functions without declaration of access
modifier, return value declaration, and name
LAMBDA EXPRESSION SYNTAX IN JAVA
(arguments) -> { body }
JAVA 8 FEATURES
anonymous inner class
lambda expression
single-line lambda expression
no-parameter lambda expression
METHOD REFERENCES
JAVA 8 FEATURES
Lambda expressions only call an existing method
 Reference to a static method
 Reference to an instance method of a particular object
 Reference to an constructor
// int Comparator.compare(T t1, T t2)
// void Consumer.accept(T t)
// T IntFunction.apply(int value)
WHY LAMBDA EXPRESSIONS IN JAVA?
JAVA 8 FEATURES
 Encourage functional programming
 Easier to distribute processing of collections over multiple threads
 More succinct and clear than anonymous inner classes
Is Lambda Expression a syntactic-sugar for Anonymous Inner Class?
HOW LAMBDA EXPRESSIONS WORK?
The lambda expression is represented by a new method, and is
invoked at run-time using invokedynamic & LambdaMetafactory
JAVA 8 FEATURES
JVM generation
JVM translation
Lambda Expression is not a syntactic-sugar for Anonymous Inner Class
STREAM API
Java 7
Lambda Expressions
Default Methods
Stream API
New Date/Time APINashorn
Java 8
Others
JAVA 8 FEATURES
DEFINITION OF STREAM
JAVA 8 FEATURES
Streams are a FP design pattern for processing
sequences of elements sequentially or in parallel
STREAM IN JAVA 8 - EXAMPLE
Given a list of photos, I want to find 5 photo names
that follow top 3 photos whose average rating is
higher than 6, sorted by rating and the total amount
of ratings given
JAVA 8 FEATURES
IMPERATIVE STYLE
JAVA 8 FEATURES
STREAM STYLE
JAVA 8 FEATURES
Coding in Stream API-way
 Internally iterates through the elements
 Manipulate the collection data easier and faster
 Focus on "what" to do instead of "how" to do it
 The ability to use multiple processor cores for collection
processing
STREAM OPERATIONS
JAVA 8 FEATURES
Intermediate operations
- Lazy processing
- Stateless: filter, map, flatMap, peek
- Stateful: distinct, sorted, skip
- Short-circuiting : limit
Terminal operations
- Eager processing
- forEach, reduce, collect, max, count
- Short-circuiting: anyMatch, allMatch,
noneMatch, findFirst, findAny
- Escape-hatch: iterator, spliterator
DEFAULT METHODS
Java 7
Lambda Expressions
Default Methods
Stream API
New Date/Time APINashorn
Java 8
Others
JAVA 8 FEATURES
How to add forEach(Consumer) method into List interface?
persons.forEach(person -> personRepo.save(person));
DEFAULT METHODS
JAVA 8 FEATURES
Default Methods allow to add default implementations to new and/or
existing methods of existing interface
CLASS-EXTENDED IN JAVA 8
JAVA 8 FEATURES
Multiple Inheritances  behaviors only, no state
‘Diamond Problem’  Solving manually
CLASS-EXTENDED IN OTHER LANGUAGES
Scala Traits (or Ruby Mix-ins)
JAVA 8 FEATURES
C# Extension Methods
NEW DATE & TIME API
Java 7
Lambda Expressions
Default Methods
Stream API
New Date/Time APINashorn
Java 8
Others
JAVA 8 FEATURES
DATE AND TIME API
 Immutable-value classes
 Domain-driven design
 Separation of chronologies
JAVA 8 FEATURES
Problems of current Date Time API
 Date, Calendar and SimpleDateFormatter are not thread-safe
 Poor API design: years start at 1900, months start at 0
 No Non-timezone dates/times, durations, periods and intervals
New Date and Time API
Great but not a Java Standard API
Joda-Time
NEW DATE AND TIME API EXAMPLE
JAVA 8 FEATURES
 LocalDate, LocalTime, LocalDateTime, ZonedDateTime
 Clock, Duration, Period, ZoneId, ZoneOffset
Domain-driven Date and Time
Date and Time API classes
NEW JAVASCRIPT ENGINE (NASHORN)
Java 7
Lambda Expressions
Default Methods
Stream API
New Date/Time APINashorn
Java 8
Others
JAVA 8 FEATURES
NEW JAVASCRIPT ENGINE (NASHORN)
JAVA 8 FEATURES
Why Nashorn Engine?
 Full 100% ECMA262-compliant (edition 5.1)
 Compiles JS to Java byte-code based on invokedynamic
 Not match V8 performance, but 2-10x faster than Rhino
 jjs command line tool
Applying Nashorn: Avartar.js and Project Avatar
OTHER FEATURES
Java 7
Lambda Expressions
Default Methods
Stream API
New Date/Time APINashorn
Java 8
Others
JAVA 8 FEATURES
OTHER FEATURES
JAVA 8 FEATURES
Static Methods on Interfaces
At beginning, Java allows static fields and static inner types in
interface, why not static methods? Yes, it is in Java 8
Optional Class
Type Annotations
3rd-parties like Checker Framework use Java Compiler Plug-in and
Pluggable Annotations Processing APIs to develop their own analyses
OTHER FEATURES (CON’T)
JAVA 8 FEATURES
Repeating Annotations
Method Parameter Reflection
 How to get name of method parameters?
 java.lang.reflect.Executable.getParameters
 Compile the source file with the -parameters
CONCLUSIONS
New Features in Java 8
Lambda Expressions
Default Methods
Stream API
New Date/Time APINashorn
Others
JAVA 8 FEATURES
Change the way we
write applications
RESOURCES
• http://www.oracle.com/technetwork/java/javase/8-
whats-new-2157071.html
• http://www.techempower.com/blog/2013/03/26/everyt
hing-about-java-8/
• http://www.takipiblog.com/2014/03/18/5-features-in-
java-8-that-will-change-how-you-code/
• http://java.dzone.com/articles/think-twice-using-java-8
• http://www.infoq.com/articles/java-8-vs-scala
• Duke 8 image [http://www.takipiblog.com/]
• Stream image [http://ricianh.blogspot.com/]
Questions
JAVA 8 FEATURES
THANK YOU
© 2013 KMS Technology

More Related Content

What's hot

Pixel Relationships Examples
Pixel Relationships ExamplesPixel Relationships Examples
Pixel Relationships ExamplesMarwa Ahmeid
 
Color Image Processing: Basics
Color Image Processing: BasicsColor Image Processing: Basics
Color Image Processing: BasicsA B Shinde
 
OMD chapter 2 Class modelling
 OMD  chapter 2 Class modelling OMD  chapter 2 Class modelling
OMD chapter 2 Class modellingjayashri kolekar
 
Big Data: Social Network Analysis
Big Data: Social Network AnalysisBig Data: Social Network Analysis
Big Data: Social Network AnalysisMichel Bruley
 
Deep Learning for Structure-from-Motion (SfM)
Deep Learning for Structure-from-Motion (SfM)Deep Learning for Structure-from-Motion (SfM)
Deep Learning for Structure-from-Motion (SfM)PetteriTeikariPhD
 
Case Study - SUN NFS
Case Study - SUN NFSCase Study - SUN NFS
Case Study - SUN NFSAshish KC
 
brain tumor detection by thresholding approach
brain tumor detection by thresholding approachbrain tumor detection by thresholding approach
brain tumor detection by thresholding approachSahil Prajapati
 
Human Activity Recognition
Human Activity RecognitionHuman Activity Recognition
Human Activity RecognitionAshwinGill1
 
Fruit Disease Detection and Classification
Fruit Disease Detection and ClassificationFruit Disease Detection and Classification
Fruit Disease Detection and ClassificationIRJET Journal
 
Computer Vision: Feature matching with RANSAC Algorithm
Computer Vision: Feature matching with RANSAC AlgorithmComputer Vision: Feature matching with RANSAC Algorithm
Computer Vision: Feature matching with RANSAC Algorithmallyn joy calcaben
 
Digital image processing
Digital image processingDigital image processing
Digital image processingABIRAMI M
 
Web mining slides
Web mining slidesWeb mining slides
Web mining slidesmahavir_a
 
Geoscience satellite image processing
Geoscience satellite image processingGeoscience satellite image processing
Geoscience satellite image processinggaurav jain
 

What's hot (20)

Process Management-Process Migration
Process Management-Process MigrationProcess Management-Process Migration
Process Management-Process Migration
 
Naming in Distributed System
Naming in Distributed SystemNaming in Distributed System
Naming in Distributed System
 
Pixel Relationships Examples
Pixel Relationships ExamplesPixel Relationships Examples
Pixel Relationships Examples
 
Color Image Processing: Basics
Color Image Processing: BasicsColor Image Processing: Basics
Color Image Processing: Basics
 
OMD chapter 2 Class modelling
 OMD  chapter 2 Class modelling OMD  chapter 2 Class modelling
OMD chapter 2 Class modelling
 
Big Data: Social Network Analysis
Big Data: Social Network AnalysisBig Data: Social Network Analysis
Big Data: Social Network Analysis
 
Human Action Recognition
Human Action RecognitionHuman Action Recognition
Human Action Recognition
 
Deep Learning for Structure-from-Motion (SfM)
Deep Learning for Structure-from-Motion (SfM)Deep Learning for Structure-from-Motion (SfM)
Deep Learning for Structure-from-Motion (SfM)
 
Case Study - SUN NFS
Case Study - SUN NFSCase Study - SUN NFS
Case Study - SUN NFS
 
brain tumor detection by thresholding approach
brain tumor detection by thresholding approachbrain tumor detection by thresholding approach
brain tumor detection by thresholding approach
 
Human Activity Recognition
Human Activity RecognitionHuman Activity Recognition
Human Activity Recognition
 
Human rights
Human rightsHuman rights
Human rights
 
Fruit Disease Detection and Classification
Fruit Disease Detection and ClassificationFruit Disease Detection and Classification
Fruit Disease Detection and Classification
 
Computer Vision: Feature matching with RANSAC Algorithm
Computer Vision: Feature matching with RANSAC AlgorithmComputer Vision: Feature matching with RANSAC Algorithm
Computer Vision: Feature matching with RANSAC Algorithm
 
Virtual machine security
Virtual machine securityVirtual machine security
Virtual machine security
 
Sds
SdsSds
Sds
 
Digital image processing
Digital image processingDigital image processing
Digital image processing
 
Web mining slides
Web mining slidesWeb mining slides
Web mining slides
 
Image compression models
Image compression modelsImage compression models
Image compression models
 
Geoscience satellite image processing
Geoscience satellite image processingGeoscience satellite image processing
Geoscience satellite image processing
 

Similar to Java 8 Features

Future of Java EE with Java SE 8
Future of Java EE with Java SE 8Future of Java EE with Java SE 8
Future of Java EE with Java SE 8Hirofumi Iwasaki
 
New Features of Java7 SE
New Features of Java7 SENew Features of Java7 SE
New Features of Java7 SEdogangoko
 
Java New Evolution
Java New EvolutionJava New Evolution
Java New EvolutionAllan Huang
 
Java 7 Dolphin manjula kollipara
Java 7 Dolphin manjula kolliparaJava 7 Dolphin manjula kollipara
Java 7 Dolphin manjula kolliparaManjula Kollipara
 
Course syllabus from ingenious
Course syllabus from ingeniousCourse syllabus from ingenious
Course syllabus from ingeniousColege Buz
 
Course syllabus from ingenious
Course syllabus from ingeniousCourse syllabus from ingenious
Course syllabus from ingeniousColege Buz
 
Java EE 6 workshop at Dallas Tech Fest 2011
Java EE 6 workshop at Dallas Tech Fest 2011Java EE 6 workshop at Dallas Tech Fest 2011
Java EE 6 workshop at Dallas Tech Fest 2011Arun Gupta
 
Lambda Behave - Java 8's Testing Framework
Lambda Behave - Java 8's Testing FrameworkLambda Behave - Java 8's Testing Framework
Lambda Behave - Java 8's Testing Frameworksara stanford
 
What's new in Java 8
What's new in Java 8What's new in Java 8
What's new in Java 8jclingan
 
The latest features coming to Java 12
The latest features coming to Java 12The latest features coming to Java 12
The latest features coming to Java 12NexSoftsys
 
Introduction of Java 8 with emphasis on Lambda Expressions and Streams
Introduction of Java 8 with emphasis on Lambda Expressions and StreamsIntroduction of Java 8 with emphasis on Lambda Expressions and Streams
Introduction of Java 8 with emphasis on Lambda Expressions and StreamsEmiel Paasschens
 
Java EE 6 & GlassFish v3: Paving the path for the future - Spark IT 2010
Java EE 6 & GlassFish v3: Paving the path for the future - Spark IT 2010Java EE 6 & GlassFish v3: Paving the path for the future - Spark IT 2010
Java EE 6 & GlassFish v3: Paving the path for the future - Spark IT 2010Arun Gupta
 
java web framework standard.20180412
java web framework standard.20180412java web framework standard.20180412
java web framework standard.20180412FirmansyahIrma1
 
Java EE 6 : Paving The Path For The Future
Java EE 6 : Paving The Path For The FutureJava EE 6 : Paving The Path For The Future
Java EE 6 : Paving The Path For The FutureIndicThreads
 
Nexthink Library - replacing a ruby on rails application with Scala and Spray
Nexthink Library - replacing a ruby on rails application with Scala and SprayNexthink Library - replacing a ruby on rails application with Scala and Spray
Nexthink Library - replacing a ruby on rails application with Scala and SprayMatthew Farwell
 
Web Applications of the future: Combining JEE6 & JavaFX
Web Applications of the future: Combining JEE6 & JavaFXWeb Applications of the future: Combining JEE6 & JavaFX
Web Applications of the future: Combining JEE6 & JavaFXPaul Bakker
 
Java Version History.pdf
Java Version History.pdfJava Version History.pdf
Java Version History.pdfSudhanshiBakre1
 

Similar to Java 8 Features (20)

Future of Java EE with Java SE 8
Future of Java EE with Java SE 8Future of Java EE with Java SE 8
Future of Java EE with Java SE 8
 
New Features of Java7 SE
New Features of Java7 SENew Features of Java7 SE
New Features of Java7 SE
 
Java New Evolution
Java New EvolutionJava New Evolution
Java New Evolution
 
java new technology
java new technologyjava new technology
java new technology
 
Java 7 Dolphin manjula kollipara
Java 7 Dolphin manjula kolliparaJava 7 Dolphin manjula kollipara
Java 7 Dolphin manjula kollipara
 
Course syllabus from ingenious
Course syllabus from ingeniousCourse syllabus from ingenious
Course syllabus from ingenious
 
Course syllabus from ingenious
Course syllabus from ingeniousCourse syllabus from ingenious
Course syllabus from ingenious
 
Java EE 6 workshop at Dallas Tech Fest 2011
Java EE 6 workshop at Dallas Tech Fest 2011Java EE 6 workshop at Dallas Tech Fest 2011
Java EE 6 workshop at Dallas Tech Fest 2011
 
Lambda Behave - Java 8's Testing Framework
Lambda Behave - Java 8's Testing FrameworkLambda Behave - Java 8's Testing Framework
Lambda Behave - Java 8's Testing Framework
 
Java 8
Java 8Java 8
Java 8
 
What's new in Java 8
What's new in Java 8What's new in Java 8
What's new in Java 8
 
The latest features coming to Java 12
The latest features coming to Java 12The latest features coming to Java 12
The latest features coming to Java 12
 
What's new in Java 11
What's new in Java 11What's new in Java 11
What's new in Java 11
 
Introduction of Java 8 with emphasis on Lambda Expressions and Streams
Introduction of Java 8 with emphasis on Lambda Expressions and StreamsIntroduction of Java 8 with emphasis on Lambda Expressions and Streams
Introduction of Java 8 with emphasis on Lambda Expressions and Streams
 
Java EE 6 & GlassFish v3: Paving the path for the future - Spark IT 2010
Java EE 6 & GlassFish v3: Paving the path for the future - Spark IT 2010Java EE 6 & GlassFish v3: Paving the path for the future - Spark IT 2010
Java EE 6 & GlassFish v3: Paving the path for the future - Spark IT 2010
 
java web framework standard.20180412
java web framework standard.20180412java web framework standard.20180412
java web framework standard.20180412
 
Java EE 6 : Paving The Path For The Future
Java EE 6 : Paving The Path For The FutureJava EE 6 : Paving The Path For The Future
Java EE 6 : Paving The Path For The Future
 
Nexthink Library - replacing a ruby on rails application with Scala and Spray
Nexthink Library - replacing a ruby on rails application with Scala and SprayNexthink Library - replacing a ruby on rails application with Scala and Spray
Nexthink Library - replacing a ruby on rails application with Scala and Spray
 
Web Applications of the future: Combining JEE6 & JavaFX
Web Applications of the future: Combining JEE6 & JavaFXWeb Applications of the future: Combining JEE6 & JavaFX
Web Applications of the future: Combining JEE6 & JavaFX
 
Java Version History.pdf
Java Version History.pdfJava Version History.pdf
Java Version History.pdf
 

Recently uploaded

Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
How To Manage Restaurant Staff -BTRESTRO
How To Manage Restaurant Staff -BTRESTROHow To Manage Restaurant Staff -BTRESTRO
How To Manage Restaurant Staff -BTRESTROmotivationalword821
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...Akihiro Suda
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 

Recently uploaded (20)

Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
How To Manage Restaurant Staff -BTRESTRO
How To Manage Restaurant Staff -BTRESTROHow To Manage Restaurant Staff -BTRESTRO
How To Manage Restaurant Staff -BTRESTRO
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 

Java 8 Features

  • 1. © 2013 KMS Technology
  • 2. JAVA 8 FEATURES TRUNG NGUYEN TECHCON 2014 KMS TECHNOLOGY VIETNAM
  • 3. JAVA VERSION HISTORY JDK 1.0 (1996) JDK 1.1 (1997) inner classes JavaBeans, JDBC, RMI, reflection, JIT JDK 1.2 (1998) strictfp keyword Swing API, Collections API J2SE 1.3 (2000) JNDI, JPDA JAVA 8 FEATURES J2SE 1.4 (2002) assert keyword Image IO API, Java Web Start J2SE 5.0 (2004) generics, annotations, enum, varagrs Java SE 6 (2006) Performance improvements Scripting Language, Java Compiler API Java SE 7 (2011) try statement, invokedynamic in JVM String in switch, diamond operation
  • 4. JAVA 8 RELEASE (MAR 18, 2014) Java 7 Lambda Expressions Default Methods Stream API New Date/Time APINashorn Java 8 JAVA 8 FEATURES Others
  • 5. LAMBDA EXPRESSIONS Java 7 Lambda Expressions Default Methods Stream API New Date/Time APINashorn Java 8 Others JAVA 8 FEATURES
  • 6. LAMBDA EXPRESSION JAVA 8 FEATURES Functions in Functional Programming Functions in Java  Are arguments, return values from other functions  Are variables and be able stored in data structures  No new types such as function types  Functional Interfaces: are interfaces with exactly one method  java.util.function package Consumer, Function, Predicate, Supplier, BiFunction, DoubleConsumer, IntPredicate, LongSupplier, … Lambda Expressions are functions without declaration of access modifier, return value declaration, and name
  • 7. LAMBDA EXPRESSION SYNTAX IN JAVA (arguments) -> { body } JAVA 8 FEATURES anonymous inner class lambda expression single-line lambda expression no-parameter lambda expression
  • 8. METHOD REFERENCES JAVA 8 FEATURES Lambda expressions only call an existing method  Reference to a static method  Reference to an instance method of a particular object  Reference to an constructor // int Comparator.compare(T t1, T t2) // void Consumer.accept(T t) // T IntFunction.apply(int value)
  • 9. WHY LAMBDA EXPRESSIONS IN JAVA? JAVA 8 FEATURES  Encourage functional programming  Easier to distribute processing of collections over multiple threads  More succinct and clear than anonymous inner classes Is Lambda Expression a syntactic-sugar for Anonymous Inner Class?
  • 10. HOW LAMBDA EXPRESSIONS WORK? The lambda expression is represented by a new method, and is invoked at run-time using invokedynamic & LambdaMetafactory JAVA 8 FEATURES JVM generation JVM translation Lambda Expression is not a syntactic-sugar for Anonymous Inner Class
  • 11. STREAM API Java 7 Lambda Expressions Default Methods Stream API New Date/Time APINashorn Java 8 Others JAVA 8 FEATURES
  • 12. DEFINITION OF STREAM JAVA 8 FEATURES Streams are a FP design pattern for processing sequences of elements sequentially or in parallel
  • 13. STREAM IN JAVA 8 - EXAMPLE Given a list of photos, I want to find 5 photo names that follow top 3 photos whose average rating is higher than 6, sorted by rating and the total amount of ratings given JAVA 8 FEATURES
  • 15. STREAM STYLE JAVA 8 FEATURES Coding in Stream API-way  Internally iterates through the elements  Manipulate the collection data easier and faster  Focus on "what" to do instead of "how" to do it  The ability to use multiple processor cores for collection processing
  • 16. STREAM OPERATIONS JAVA 8 FEATURES Intermediate operations - Lazy processing - Stateless: filter, map, flatMap, peek - Stateful: distinct, sorted, skip - Short-circuiting : limit Terminal operations - Eager processing - forEach, reduce, collect, max, count - Short-circuiting: anyMatch, allMatch, noneMatch, findFirst, findAny - Escape-hatch: iterator, spliterator
  • 17. DEFAULT METHODS Java 7 Lambda Expressions Default Methods Stream API New Date/Time APINashorn Java 8 Others JAVA 8 FEATURES
  • 18. How to add forEach(Consumer) method into List interface? persons.forEach(person -> personRepo.save(person)); DEFAULT METHODS JAVA 8 FEATURES Default Methods allow to add default implementations to new and/or existing methods of existing interface
  • 19. CLASS-EXTENDED IN JAVA 8 JAVA 8 FEATURES Multiple Inheritances  behaviors only, no state ‘Diamond Problem’  Solving manually
  • 20. CLASS-EXTENDED IN OTHER LANGUAGES Scala Traits (or Ruby Mix-ins) JAVA 8 FEATURES C# Extension Methods
  • 21. NEW DATE & TIME API Java 7 Lambda Expressions Default Methods Stream API New Date/Time APINashorn Java 8 Others JAVA 8 FEATURES
  • 22. DATE AND TIME API  Immutable-value classes  Domain-driven design  Separation of chronologies JAVA 8 FEATURES Problems of current Date Time API  Date, Calendar and SimpleDateFormatter are not thread-safe  Poor API design: years start at 1900, months start at 0  No Non-timezone dates/times, durations, periods and intervals New Date and Time API Great but not a Java Standard API Joda-Time
  • 23. NEW DATE AND TIME API EXAMPLE JAVA 8 FEATURES  LocalDate, LocalTime, LocalDateTime, ZonedDateTime  Clock, Duration, Period, ZoneId, ZoneOffset Domain-driven Date and Time Date and Time API classes
  • 24. NEW JAVASCRIPT ENGINE (NASHORN) Java 7 Lambda Expressions Default Methods Stream API New Date/Time APINashorn Java 8 Others JAVA 8 FEATURES
  • 25. NEW JAVASCRIPT ENGINE (NASHORN) JAVA 8 FEATURES Why Nashorn Engine?  Full 100% ECMA262-compliant (edition 5.1)  Compiles JS to Java byte-code based on invokedynamic  Not match V8 performance, but 2-10x faster than Rhino  jjs command line tool Applying Nashorn: Avartar.js and Project Avatar
  • 26. OTHER FEATURES Java 7 Lambda Expressions Default Methods Stream API New Date/Time APINashorn Java 8 Others JAVA 8 FEATURES
  • 27. OTHER FEATURES JAVA 8 FEATURES Static Methods on Interfaces At beginning, Java allows static fields and static inner types in interface, why not static methods? Yes, it is in Java 8 Optional Class Type Annotations 3rd-parties like Checker Framework use Java Compiler Plug-in and Pluggable Annotations Processing APIs to develop their own analyses
  • 28. OTHER FEATURES (CON’T) JAVA 8 FEATURES Repeating Annotations Method Parameter Reflection  How to get name of method parameters?  java.lang.reflect.Executable.getParameters  Compile the source file with the -parameters
  • 29. CONCLUSIONS New Features in Java 8 Lambda Expressions Default Methods Stream API New Date/Time APINashorn Others JAVA 8 FEATURES Change the way we write applications
  • 30. RESOURCES • http://www.oracle.com/technetwork/java/javase/8- whats-new-2157071.html • http://www.techempower.com/blog/2013/03/26/everyt hing-about-java-8/ • http://www.takipiblog.com/2014/03/18/5-features-in- java-8-that-will-change-how-you-code/ • http://java.dzone.com/articles/think-twice-using-java-8 • http://www.infoq.com/articles/java-8-vs-scala • Duke 8 image [http://www.takipiblog.com/] • Stream image [http://ricianh.blogspot.com/]
  • 32. THANK YOU © 2013 KMS Technology