SlideShare une entreprise Scribd logo
1  sur  40
WHAT’S NEW IN JAVA 8
ABOUT ME Rajmahendra Hegde (Raj)
• Working for ValueLabs as Scrum Master/Project
Lead
• 14 years Java development
• JUG Hyderabad Lead
• NetBeans Dream Team Member
• JCP Individual and Expert Group Member for 3
JSRs
• Comitter / Contributor: JBake, Forge, NetBeans,
eWidgetFX, JavaFX, Gradle, Agorava, JRebirth,
ScalaFX
Twitter: @rajonjava
GitHub: rajmahendra
LinkedIn: rajmahendra
AGENDA
 Lambda
 Streams
 Date & Time
 Nashorn
 Java FX
JAVA LAMBDA !
Java with functional style.
JAVA LAMBDA
 Beginning of Functional flavor into Java platform
 Lambda provides anonymous function to Java
 Replaces the old use of Anonymous inner classes
 Write more compact code
 Parallel programming easier
ANONYMOUS INNER CLASS
LAMBDAFIDE ANONYMOUS INNER CLASS
LAMBDA EXPRESSION
 ( ) ->
 ( ) -> { }
 a -> a
 x -> { int y=4; return x * y; }
LAMBDA & FUNCTIONAL INTERFACE
 Functional interface are interface with only one
method.
 Java space is filled of such Interfaces
 java.lang.Runnable.run();
 java.util.Comparator.compare(T a, Tb);
 java.awt.event.ActionListener.actionPerformed(
ActionEvent e)
JAVA8 LAMBDA PACKAGE
 Additionally Java8 also provides
FunctionalInterface in package java.util.function to
use with Lambdas. This package contains more
than 40 commonly used FI
 Predicate<T>.test(T t) - Represents a predicate
(boolean-valued function) of one argument
 Consumer<T>.accept(T t) - Represents an operation
that accepts a single input argument and returns no
result
 Function<T, R>.R accept(T t) - Represents a function
that accepts one argument and produces a result
 Supplier<T>. T get() -Represents a supplier of results
 …
@FUNCTIONALINTERFACE
 FunctionalInterface = Interface with only one
method
 Annotation is optional. Its only to make sure the
interface is a FunctionalInterface
 Any interface with only one method can be
considered as FunctionalInterface
LAMBDA TO LOCAL VARIABLE
VARIABLE CAPTURE
 Lambda can interact with the variable outside of its
body
 Using the variables outside of the Lambda
expression is called Variable Capture
 Effectively final
LAMBDA VS ANONYMOUS INNER CLASS
 Lambda != Anonymous Inner Class
 Inner class can have state
 Inner class can have multiple methods
 this points to the object instance in a inner class
but points to the enclosed object in Lambda
 Lambda != Anonymous Inner Class
METHOD REFERENCE
 Use method reference when you use Lambda
expression
 Reduces boilerplate code
 NOTE: return type of lambda expression must
match with the signature of the referred method
METHOD REFERENCE TYPES
 Static Method
 Printer::print
 Instance Method
 myObject::print
 Constructor
 Page::new
DEFAULT METHOD - INTERFACE
 Provides a way to add new methods to interface
without breaking the old implementation
 default keyword is introduced to do this magic
NO MORE NULLPOINTEREXCEPTION !
 Wrapper class to guard from Null Exception
 java.util.Optional<T>
 It contain a data or a empty
STREAMS
STREAMS
 Streams are functional programming design pattern
 Helps in processing sequential elements as
sequentially or parallel
 In java we use in many different places
 Retrieve database query as list objects
 Iterate over xml or json elements
 Read multiple lines
 Collections, map etc.
STREAMS IN JAVA
 To create a stream you use a Source collection
 Add a filter option to the stream Intermediate
operation pipeline
 And ends with Terminal operation which starts the
stream process
STREAM LIFECYCLE
 Creation – Stream is created with the collection
object from source
 Configure – get configured with the list of pipeline
operators
 Execution – Streams Terminal operation triggers
the stream to starts by pulling objects into the
pipeline
 Cleanup
DATE & TIME API
OLD DATE/TIME API
 java.util.Date
 java.sql.Date
 java.util.Calendar
 java.util.GregorianCalendar
 java.util.TimeZone
 java.text.DateFormat
 java.text.SimpleDateFormat
ISSUES WITH OLD API
 All are just utility class (in java.util package or in
java.text)
 Date class contains both Date and Time
 Different Date class for SQL!
 Date doesn't have timezone
 Month is zero based, year is 1900 based.
 Not thread safe by default
 Arithmetic operations are hard to use
DATE AND TIME API
 New dedicated date time package java.time
 Dedicated class for Date and time LocalDate and
LocalTime
 A composite class for both LocalDateTime
 Numerous way to create Date time objects
 Support for Truncation, TimeZones, Periods,
Durations and Chronologies
 More fluent, clean and simple API
 Immutable classes
LOCALDATE
 Year-Month-Day
 Only for Date manipulation
 Stores or create one particular Date
LOCALTIME
 Hours-Minutes-Seconds-nano
LOCALDATETIME
 Combination of LocalDate & LocalTime
 All methods of both class available
TIMEZONE
 Numerous timezones are available
 Some time complex to manipulate
 Some time it may change frequently
 TimeZone Classes
 ZoneId – Europe/London etc.
 ZoneOffset – offset from UTC time
 ZoneRules – defines timezone rules
 ZonedDateTime – TimeZone aware Datetime class
DURATION
 Time based amount of time
PERIOD
 Date based amount of time
NASHORN
NASHORN
 Nashorn is a JavaScript Engine developed on Java
 Light-weight, high-performance integrated into JRE
 ECMAScript-262 Edition 5.1 language specification
compliance
 Java 8 shipped with a command-line tool called jjs
 JDK 6 already shipped with Mozilla’s Rhino
JavaScript Engine.
CALLING JAVASCRIPT FROM JAVA
CALLING JAVA FROM JAVASCRIPT
JAVAFX
• http://www.slideshare.net/rajmahendra/javafx-2-rich-
desktop-platform
• http://www.slideshare.net/Codemotion/codemotion-
whatsnewforjavafxinjdk8
JAVA 9!
 September 22nd 2016
 Timeline
 2015-12-10 Feature Complete
 2016-02-04 All Tests Run
 2016-02-25 Ramp down Start
 2016-04-21 Zero Bug Bounce
 2016-06-16 Ramp down Phase 2
 2016-07-21 Final Release Candidate
 2016-09-22 General Availability
 Project Jigsaw
 REPL
 …
Q & A
Rajmahendra Hegde
http://meetup.com/jughyderabad
Twitter: @rajonjava GitHub: rajmahendra
LinkedIn: rajmahendra SllideShare: rajmahendra
Rajmahendra Hegde
http://meetup.com/jughyderabad
Twitter: @rajonjava GitHub: rajmahendra LinkedIn: rajmahendra SllideShare: rajmahendra

Contenu connexe

Tendances

Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScriptRangana Sampath
 
A Scala tutorial
A Scala tutorialA Scala tutorial
A Scala tutorialDima Statz
 
Drilling the Async Library
Drilling the Async LibraryDrilling the Async Library
Drilling the Async LibraryKnoldus Inc.
 
Functional programming in scala
Functional programming in scalaFunctional programming in scala
Functional programming in scalaStratio
 
A Brief, but Dense, Intro to Scala
A Brief, but Dense, Intro to ScalaA Brief, but Dense, Intro to Scala
A Brief, but Dense, Intro to ScalaDerek Chen-Becker
 
What's a macro?: Learning by Examples / Scalaのマクロに実用例から触れてみよう!
What's a macro?: Learning by Examples / Scalaのマクロに実用例から触れてみよう!What's a macro?: Learning by Examples / Scalaのマクロに実用例から触れてみよう!
What's a macro?: Learning by Examples / Scalaのマクロに実用例から触れてみよう!scalaconfjp
 
Python Lambda Function
Python Lambda FunctionPython Lambda Function
Python Lambda FunctionMd Soyaib
 
Functional programming with Java 8
Functional programming with Java 8Functional programming with Java 8
Functional programming with Java 8Talha Ocakçı
 
Scala : language of the future
Scala : language of the futureScala : language of the future
Scala : language of the futureAnsviaLab
 
From Ruby to Scala
From Ruby to ScalaFrom Ruby to Scala
From Ruby to Scalatod esking
 
20160520 what youneedtoknowaboutlambdas
20160520 what youneedtoknowaboutlambdas20160520 what youneedtoknowaboutlambdas
20160520 what youneedtoknowaboutlambdasshinolajla
 
New Features of JAVA SE8
New Features of JAVA SE8New Features of JAVA SE8
New Features of JAVA SE8Dinesh Pathak
 
I18nize Scala programs à la gettext
I18nize Scala programs à la gettextI18nize Scala programs à la gettext
I18nize Scala programs à la gettextNgoc Dao
 
Refactoring to Scala DSLs and LiftOff 2009 Recap
Refactoring to Scala DSLs and LiftOff 2009 RecapRefactoring to Scala DSLs and LiftOff 2009 Recap
Refactoring to Scala DSLs and LiftOff 2009 RecapDave Orme
 
introduction to javascript
introduction to javascriptintroduction to javascript
introduction to javascriptKumar
 

Tendances (20)

Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
Lecture1
Lecture1Lecture1
Lecture1
 
A Scala tutorial
A Scala tutorialA Scala tutorial
A Scala tutorial
 
Drilling the Async Library
Drilling the Async LibraryDrilling the Async Library
Drilling the Async Library
 
Functional programming in scala
Functional programming in scalaFunctional programming in scala
Functional programming in scala
 
Java 8 Bootcamp
Java 8 BootcampJava 8 Bootcamp
Java 8 Bootcamp
 
A Brief, but Dense, Intro to Scala
A Brief, but Dense, Intro to ScalaA Brief, but Dense, Intro to Scala
A Brief, but Dense, Intro to Scala
 
Java 8 features
Java 8 featuresJava 8 features
Java 8 features
 
What's a macro?: Learning by Examples / Scalaのマクロに実用例から触れてみよう!
What's a macro?: Learning by Examples / Scalaのマクロに実用例から触れてみよう!What's a macro?: Learning by Examples / Scalaのマクロに実用例から触れてみよう!
What's a macro?: Learning by Examples / Scalaのマクロに実用例から触れてみよう!
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 
JS - Basics
JS - BasicsJS - Basics
JS - Basics
 
Python Lambda Function
Python Lambda FunctionPython Lambda Function
Python Lambda Function
 
Functional programming with Java 8
Functional programming with Java 8Functional programming with Java 8
Functional programming with Java 8
 
Scala : language of the future
Scala : language of the futureScala : language of the future
Scala : language of the future
 
From Ruby to Scala
From Ruby to ScalaFrom Ruby to Scala
From Ruby to Scala
 
20160520 what youneedtoknowaboutlambdas
20160520 what youneedtoknowaboutlambdas20160520 what youneedtoknowaboutlambdas
20160520 what youneedtoknowaboutlambdas
 
New Features of JAVA SE8
New Features of JAVA SE8New Features of JAVA SE8
New Features of JAVA SE8
 
I18nize Scala programs à la gettext
I18nize Scala programs à la gettextI18nize Scala programs à la gettext
I18nize Scala programs à la gettext
 
Refactoring to Scala DSLs and LiftOff 2009 Recap
Refactoring to Scala DSLs and LiftOff 2009 RecapRefactoring to Scala DSLs and LiftOff 2009 Recap
Refactoring to Scala DSLs and LiftOff 2009 Recap
 
introduction to javascript
introduction to javascriptintroduction to javascript
introduction to javascript
 

En vedette

JSR 354 - Money and Currency API
JSR 354 - Money and Currency APIJSR 354 - Money and Currency API
JSR 354 - Money and Currency APIRajmahendra Hegde
 
JUGChennai UserGroup BestPractices
JUGChennai UserGroup BestPracticesJUGChennai UserGroup BestPractices
JUGChennai UserGroup BestPracticesRajmahendra Hegde
 
JavaFX 2 Rich Desktop Platform
JavaFX 2 Rich Desktop PlatformJavaFX 2 Rich Desktop Platform
JavaFX 2 Rich Desktop PlatformRajmahendra Hegde
 
JUGHyderabad - APOUC '15 - 4 minutes pitch
JUGHyderabad - APOUC '15 - 4 minutes pitchJUGHyderabad - APOUC '15 - 4 minutes pitch
JUGHyderabad - APOUC '15 - 4 minutes pitchRajmahendra Hegde
 
Gradle build tool that rocks with DSL JavaOne India 4th May 2012
Gradle build tool that rocks with DSL JavaOne India 4th May 2012Gradle build tool that rocks with DSL JavaOne India 4th May 2012
Gradle build tool that rocks with DSL JavaOne India 4th May 2012Rajmahendra Hegde
 
Hyderabad Scala Community first meetup
Hyderabad Scala Community first meetupHyderabad Scala Community first meetup
Hyderabad Scala Community first meetupRajmahendra Hegde
 
JavaFX JumpStart @JavaOne 2016
JavaFX JumpStart @JavaOne 2016JavaFX JumpStart @JavaOne 2016
JavaFX JumpStart @JavaOne 2016Hendrik Ebbers
 

En vedette (10)

JSR 354 - Money and Currency API
JSR 354 - Money and Currency APIJSR 354 - Money and Currency API
JSR 354 - Money and Currency API
 
JUGChennai UserGroup BestPractices
JUGChennai UserGroup BestPracticesJUGChennai UserGroup BestPractices
JUGChennai UserGroup BestPractices
 
JavaFX 2 Rich Desktop Platform
JavaFX 2 Rich Desktop PlatformJavaFX 2 Rich Desktop Platform
JavaFX 2 Rich Desktop Platform
 
Inside jcp
Inside jcpInside jcp
Inside jcp
 
About JUGChennai 2011
About JUGChennai 2011About JUGChennai 2011
About JUGChennai 2011
 
JUGHyderabad - APOUC '15 - 4 minutes pitch
JUGHyderabad - APOUC '15 - 4 minutes pitchJUGHyderabad - APOUC '15 - 4 minutes pitch
JUGHyderabad - APOUC '15 - 4 minutes pitch
 
Gradle build tool that rocks with DSL JavaOne India 4th May 2012
Gradle build tool that rocks with DSL JavaOne India 4th May 2012Gradle build tool that rocks with DSL JavaOne India 4th May 2012
Gradle build tool that rocks with DSL JavaOne India 4th May 2012
 
Javafx
JavafxJavafx
Javafx
 
Hyderabad Scala Community first meetup
Hyderabad Scala Community first meetupHyderabad Scala Community first meetup
Hyderabad Scala Community first meetup
 
JavaFX JumpStart @JavaOne 2016
JavaFX JumpStart @JavaOne 2016JavaFX JumpStart @JavaOne 2016
JavaFX JumpStart @JavaOne 2016
 

Similaire à What’s new in java 8

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 8 lambdas expressions
Java 8 lambdas expressionsJava 8 lambdas expressions
Java 8 lambdas expressionsLars Lemos
 
Functional Programming In Jdk8
Functional Programming In Jdk8 Functional Programming In Jdk8
Functional Programming In Jdk8 Bansilal Haudakari
 
Lambda Expressions Java 8 Features usage
Lambda Expressions  Java 8 Features usageLambda Expressions  Java 8 Features usage
Lambda Expressions Java 8 Features usageAsmaShaikh478737
 
2014 10 java 8 major new language features
2014 10 java 8 major new language features2014 10 java 8 major new language features
2014 10 java 8 major new language featuresNeil Brown
 
Typescript in 30mins
Typescript in 30mins Typescript in 30mins
Typescript in 30mins Udaya Kumar
 
A Tour Of Scala
A Tour Of ScalaA Tour Of Scala
A Tour Of Scalafanf42
 
Java se 8 fundamentals
Java se 8 fundamentalsJava se 8 fundamentals
Java se 8 fundamentalsmegharajk
 
Develop realtime web with Scala and Xitrum
Develop realtime web with Scala and XitrumDevelop realtime web with Scala and Xitrum
Develop realtime web with Scala and XitrumNgoc Dao
 
A-Brief-Introduction-To-JAVA8_By_Srimanta_Sahu
A-Brief-Introduction-To-JAVA8_By_Srimanta_SahuA-Brief-Introduction-To-JAVA8_By_Srimanta_Sahu
A-Brief-Introduction-To-JAVA8_By_Srimanta_SahuSrimanta Sahu
 
What's new in Java 8
What's new in Java 8What's new in Java 8
What's new in Java 8Kyle Smith
 
Java 8 - Features Overview
Java 8 - Features OverviewJava 8 - Features Overview
Java 8 - Features OverviewSergii Stets
 

Similaire à What’s new in java 8 (20)

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
 
Java8 features
Java8 featuresJava8 features
Java8 features
 
Java features
Java featuresJava features
Java features
 
Java 8 lambdas expressions
Java 8 lambdas expressionsJava 8 lambdas expressions
Java 8 lambdas expressions
 
Functional Programming In Jdk8
Functional Programming In Jdk8 Functional Programming In Jdk8
Functional Programming In Jdk8
 
Lambda Expressions Java 8 Features usage
Lambda Expressions  Java 8 Features usageLambda Expressions  Java 8 Features usage
Lambda Expressions Java 8 Features usage
 
Lambdas in Java 8
Lambdas in Java 8Lambdas in Java 8
Lambdas in Java 8
 
Java SE 8 & EE 7 Launch
Java SE 8 & EE 7 LaunchJava SE 8 & EE 7 Launch
Java SE 8 & EE 7 Launch
 
2014 10 java 8 major new language features
2014 10 java 8 major new language features2014 10 java 8 major new language features
2014 10 java 8 major new language features
 
Typescript in 30mins
Typescript in 30mins Typescript in 30mins
Typescript in 30mins
 
Insight into java 1.8, OOP VS FP
Insight into java 1.8, OOP VS FPInsight into java 1.8, OOP VS FP
Insight into java 1.8, OOP VS FP
 
Java 8
Java 8Java 8
Java 8
 
A Tour Of Scala
A Tour Of ScalaA Tour Of Scala
A Tour Of Scala
 
Scala tutorial
Scala tutorialScala tutorial
Scala tutorial
 
Scala tutorial
Scala tutorialScala tutorial
Scala tutorial
 
Java se 8 fundamentals
Java se 8 fundamentalsJava se 8 fundamentals
Java se 8 fundamentals
 
Develop realtime web with Scala and Xitrum
Develop realtime web with Scala and XitrumDevelop realtime web with Scala and Xitrum
Develop realtime web with Scala and Xitrum
 
A-Brief-Introduction-To-JAVA8_By_Srimanta_Sahu
A-Brief-Introduction-To-JAVA8_By_Srimanta_SahuA-Brief-Introduction-To-JAVA8_By_Srimanta_Sahu
A-Brief-Introduction-To-JAVA8_By_Srimanta_Sahu
 
What's new in Java 8
What's new in Java 8What's new in Java 8
What's new in Java 8
 
Java 8 - Features Overview
Java 8 - Features OverviewJava 8 - Features Overview
Java 8 - Features Overview
 

Dernier

How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 

Dernier (20)

DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 

What’s new in java 8

  • 2. ABOUT ME Rajmahendra Hegde (Raj) • Working for ValueLabs as Scrum Master/Project Lead • 14 years Java development • JUG Hyderabad Lead • NetBeans Dream Team Member • JCP Individual and Expert Group Member for 3 JSRs • Comitter / Contributor: JBake, Forge, NetBeans, eWidgetFX, JavaFX, Gradle, Agorava, JRebirth, ScalaFX Twitter: @rajonjava GitHub: rajmahendra LinkedIn: rajmahendra
  • 3. AGENDA  Lambda  Streams  Date & Time  Nashorn  Java FX
  • 4. JAVA LAMBDA ! Java with functional style.
  • 5. JAVA LAMBDA  Beginning of Functional flavor into Java platform  Lambda provides anonymous function to Java  Replaces the old use of Anonymous inner classes  Write more compact code  Parallel programming easier
  • 8. LAMBDA EXPRESSION  ( ) ->  ( ) -> { }  a -> a  x -> { int y=4; return x * y; }
  • 9. LAMBDA & FUNCTIONAL INTERFACE  Functional interface are interface with only one method.  Java space is filled of such Interfaces  java.lang.Runnable.run();  java.util.Comparator.compare(T a, Tb);  java.awt.event.ActionListener.actionPerformed( ActionEvent e)
  • 10. JAVA8 LAMBDA PACKAGE  Additionally Java8 also provides FunctionalInterface in package java.util.function to use with Lambdas. This package contains more than 40 commonly used FI  Predicate<T>.test(T t) - Represents a predicate (boolean-valued function) of one argument  Consumer<T>.accept(T t) - Represents an operation that accepts a single input argument and returns no result  Function<T, R>.R accept(T t) - Represents a function that accepts one argument and produces a result  Supplier<T>. T get() -Represents a supplier of results  …
  • 11. @FUNCTIONALINTERFACE  FunctionalInterface = Interface with only one method  Annotation is optional. Its only to make sure the interface is a FunctionalInterface  Any interface with only one method can be considered as FunctionalInterface
  • 12. LAMBDA TO LOCAL VARIABLE
  • 13. VARIABLE CAPTURE  Lambda can interact with the variable outside of its body  Using the variables outside of the Lambda expression is called Variable Capture  Effectively final
  • 14. LAMBDA VS ANONYMOUS INNER CLASS  Lambda != Anonymous Inner Class  Inner class can have state  Inner class can have multiple methods  this points to the object instance in a inner class but points to the enclosed object in Lambda  Lambda != Anonymous Inner Class
  • 15. METHOD REFERENCE  Use method reference when you use Lambda expression  Reduces boilerplate code  NOTE: return type of lambda expression must match with the signature of the referred method
  • 16. METHOD REFERENCE TYPES  Static Method  Printer::print  Instance Method  myObject::print  Constructor  Page::new
  • 17. DEFAULT METHOD - INTERFACE  Provides a way to add new methods to interface without breaking the old implementation  default keyword is introduced to do this magic
  • 18. NO MORE NULLPOINTEREXCEPTION !  Wrapper class to guard from Null Exception  java.util.Optional<T>  It contain a data or a empty
  • 20. STREAMS  Streams are functional programming design pattern  Helps in processing sequential elements as sequentially or parallel  In java we use in many different places  Retrieve database query as list objects  Iterate over xml or json elements  Read multiple lines  Collections, map etc.
  • 21. STREAMS IN JAVA  To create a stream you use a Source collection  Add a filter option to the stream Intermediate operation pipeline  And ends with Terminal operation which starts the stream process
  • 22. STREAM LIFECYCLE  Creation – Stream is created with the collection object from source  Configure – get configured with the list of pipeline operators  Execution – Streams Terminal operation triggers the stream to starts by pulling objects into the pipeline  Cleanup
  • 23. DATE & TIME API
  • 24. OLD DATE/TIME API  java.util.Date  java.sql.Date  java.util.Calendar  java.util.GregorianCalendar  java.util.TimeZone  java.text.DateFormat  java.text.SimpleDateFormat
  • 25. ISSUES WITH OLD API  All are just utility class (in java.util package or in java.text)  Date class contains both Date and Time  Different Date class for SQL!  Date doesn't have timezone  Month is zero based, year is 1900 based.  Not thread safe by default  Arithmetic operations are hard to use
  • 26. DATE AND TIME API  New dedicated date time package java.time  Dedicated class for Date and time LocalDate and LocalTime  A composite class for both LocalDateTime  Numerous way to create Date time objects  Support for Truncation, TimeZones, Periods, Durations and Chronologies  More fluent, clean and simple API  Immutable classes
  • 27. LOCALDATE  Year-Month-Day  Only for Date manipulation  Stores or create one particular Date
  • 29. LOCALDATETIME  Combination of LocalDate & LocalTime  All methods of both class available
  • 30. TIMEZONE  Numerous timezones are available  Some time complex to manipulate  Some time it may change frequently  TimeZone Classes  ZoneId – Europe/London etc.  ZoneOffset – offset from UTC time  ZoneRules – defines timezone rules  ZonedDateTime – TimeZone aware Datetime class
  • 31. DURATION  Time based amount of time
  • 32. PERIOD  Date based amount of time
  • 34. NASHORN  Nashorn is a JavaScript Engine developed on Java  Light-weight, high-performance integrated into JRE  ECMAScript-262 Edition 5.1 language specification compliance  Java 8 shipped with a command-line tool called jjs  JDK 6 already shipped with Mozilla’s Rhino JavaScript Engine.
  • 36. CALLING JAVA FROM JAVASCRIPT
  • 38. JAVA 9!  September 22nd 2016  Timeline  2015-12-10 Feature Complete  2016-02-04 All Tests Run  2016-02-25 Ramp down Start  2016-04-21 Zero Bug Bounce  2016-06-16 Ramp down Phase 2  2016-07-21 Final Release Candidate  2016-09-22 General Availability  Project Jigsaw  REPL  …
  • 39. Q & A Rajmahendra Hegde http://meetup.com/jughyderabad Twitter: @rajonjava GitHub: rajmahendra LinkedIn: rajmahendra SllideShare: rajmahendra
  • 40. Rajmahendra Hegde http://meetup.com/jughyderabad Twitter: @rajonjava GitHub: rajmahendra LinkedIn: rajmahendra SllideShare: rajmahendra