SlideShare uma empresa Scribd logo
1 de 13
PRESENTATION
ON
JAVA 8
CONTENT
• Introduction
• Lambda Expression
• Functional Interfaces
• Default methods
• Predicates
• Functions
• Double colon operator
• Stream API
• Date and Time API
• Project
Introduction
• java 7 – July 28th 2011
• Java 8 - March 18th 2014
• Java 9 - September 22nd 2016
• Java 10 – 2018
• After Java 1.5version, Java 8 is the next major version. Before Java 8,
sun people gave importance only for objects but in 1.8version oracle
people gave the importance for functional aspects of programming to
bring its benefits to Java.ie it doesn’t mean Java is functional oriented
programming language
Lambda Expression
• Lambda Expression is just an anonymous (nameless) function.
That means the function which doesn’t have the name, return
type and access modifiers.
public void m1()
{
sop(“hello”);
}
() ->{
sop(“hello”);
}
Functional Interfaces
• If an interface contain only one abstract method, such type of interfaces are called functional
interfaces and the method is called functional method or single abstract method (SAM)
• Ex->
• 1) Runnable -> It contains only run() method
• 2) Comparable ->It contains only compareTo() method
• 3) ActionListener -> It contains only actionPerformed()
• 4) Callable -> It contains only call() method
interface Interf {
public abstract void m1();
default void m2() {
System.out.println (“hello”); } }
@Functional Interface
Interface Interf {
public void m1();
}
Default methods
• Until 1.7 version onwards inside interface we can take only public
abstract methods and public static final variables
• But from 1.8 version onwards in addition to these, we can declare
default concrete methods also inside interface, which are also
known as defender methods.
default void m1()
{
System.out.println (“Default Method”);
}
• Interface default methods are by-default available to all
implementation classes. Based on requirement implementation
class can use these default methods directly or can override
Predicates
• A predicate is a function with a single argument and returns
boolean value.
• To implement predicate functions in Java, Oracle people
introduced Predicate interface in 1.8 version (i.e.,Predicate)
• Predicate interface present in Java.util.function package.
• public boolean test(Integer I) {
if (I >10) {
return true; }
else { return false;
} }
With predicate
predicate p = I ->(I >10);
System.out.println (p.test(100)); true
System.out.println (p.test(7)); false
Functions
• Functions are exactly same as predicates except that functions can return
any type of result but function should (can) return only one value and
that value can be any type as per our requirement
• To implement functions oracle people introduced Function interface in
1.8version.
• interface function(T,R) {
• public R apply(T t);
• }
Double colon operator
• Functional Interface method can be mapped to our
specified method by using :: (double colon) operator. This
is called method reference.
• Our specified method can be either static method or
instance method
Syntax:
if our specified method is static method
Classname::methodName
if the method is instance method
Objref::methodName
Stream API
• To process objects of the collection, in 1.8 version Streams concept introduced.
• java.util streams meant for processing objects from the collection. I and Java.io
streams meant for processing binary and character data with respect to file.
• We can create a stream object to the collection by using stream() method of
Collection interface. stream() method is a default method added to the Collection in
1.8 version.
• default Stream stream()
• Stream s = c.stream();
• Stream is an interface present in java.util.stream. Once we got the stream, by using
that we can process objects of that collection. We can process the objects in the
following 2 phases
• Configuration
• Mapping
Date and Time API
• Joda-Time API
• Until Java 1.7version the classes present in Java.util package to
handle Date and Time (like Date, Calendar, TimeZoneetc) are
not up to the mark with respect to convenience and
performance.
• To overcome this problem in the 1.8version oracle people
introduced Joda-Time API. This API developed by joda.org and
available in Java in the form of Java.time package.
Project
#Library
Management
THANK
YOU

Mais conteúdo relacionado

Mais procurados (20)

Java 8 lambda
Java 8 lambdaJava 8 lambda
Java 8 lambda
 
Core java Essentials
Core java EssentialsCore java Essentials
Core java Essentials
 
Files in java
Files in javaFiles in java
Files in java
 
Collections framework in java
Collections framework in javaCollections framework in java
Collections framework in java
 
Introduction to java 8 stream api
Introduction to java 8 stream apiIntroduction to java 8 stream api
Introduction to java 8 stream api
 
Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.
 
Optional in Java 8
Optional in Java 8Optional in Java 8
Optional in Java 8
 
Packages in java
Packages in javaPackages in java
Packages in java
 
Java 8 Lambda Expressions
Java 8 Lambda ExpressionsJava 8 Lambda Expressions
Java 8 Lambda Expressions
 
Exception Handling in JAVA
Exception Handling in JAVAException Handling in JAVA
Exception Handling in JAVA
 
Java Collections Framework
Java Collections FrameworkJava Collections Framework
Java Collections Framework
 
How Hashmap works internally in java
How Hashmap works internally  in javaHow Hashmap works internally  in java
How Hashmap works internally in java
 
Java multi threading
Java multi threadingJava multi threading
Java multi threading
 
Enumeration in Java Explained | Java Tutorial | Edureka
Enumeration in Java Explained | Java Tutorial | EdurekaEnumeration in Java Explained | Java Tutorial | Edureka
Enumeration in Java Explained | Java Tutorial | Edureka
 
String in java
String in javaString in java
String in java
 
Java Collection framework
Java Collection frameworkJava Collection framework
Java Collection framework
 
Java And Multithreading
Java And MultithreadingJava And Multithreading
Java And Multithreading
 
JDBC – Java Database Connectivity
JDBC – Java Database ConnectivityJDBC – Java Database Connectivity
JDBC – Java Database Connectivity
 
Spring Core
Spring CoreSpring Core
Spring Core
 
Java IO
Java IOJava IO
Java IO
 

Semelhante a java 8 new features

Software Uni Conf October 2014
Software Uni Conf October 2014Software Uni Conf October 2014
Software Uni Conf October 2014Nayden Gochev
 
Java- Updates in java8-Mazenet solution
Java- Updates in java8-Mazenet solutionJava- Updates in java8-Mazenet solution
Java- Updates in java8-Mazenet solutionMazenetsolution
 
New Features of JAVA SE8
New Features of JAVA SE8New Features of JAVA SE8
New Features of JAVA SE8Dinesh Pathak
 
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
 
Automatic Migration of Legacy Java Method Implementations to Interfaces
Automatic Migration of Legacy Java Method Implementations to InterfacesAutomatic Migration of Legacy Java Method Implementations to Interfaces
Automatic Migration of Legacy Java Method Implementations to InterfacesRaffi Khatchadourian
 
Java 8 - Project Lambda
Java 8 - Project LambdaJava 8 - Project Lambda
Java 8 - Project LambdaRahman USTA
 
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
 
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov Nayden Gochev
 
Defaultification Refactoring: A Tool for Automatically Converting Java Method...
Defaultification Refactoring: A Tool for Automatically Converting Java Method...Defaultification Refactoring: A Tool for Automatically Converting Java Method...
Defaultification Refactoring: A Tool for Automatically Converting Java Method...Raffi Khatchadourian
 
Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...
Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...
Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...Raffi Khatchadourian
 
Java 9 features
Java 9 featuresJava 9 features
Java 9 featuresshrinath97
 
Automated Refactoring of Legacy Java Software to Default Methods Talk at GMU
Automated Refactoring of Legacy Java Software to Default Methods Talk at GMUAutomated Refactoring of Legacy Java Software to Default Methods Talk at GMU
Automated Refactoring of Legacy Java Software to Default Methods Talk at GMURaffi Khatchadourian
 
Java For beginners and CSIT and IT students
Java  For beginners and CSIT and IT studentsJava  For beginners and CSIT and IT students
Java For beginners and CSIT and IT studentsPartnered Health
 

Semelhante a java 8 new features (20)

Software Uni Conf October 2014
Software Uni Conf October 2014Software Uni Conf October 2014
Software Uni Conf October 2014
 
Java- Updates in java8-Mazenet solution
Java- Updates in java8-Mazenet solutionJava- Updates in java8-Mazenet solution
Java- Updates in java8-Mazenet solution
 
New Features of JAVA SE8
New Features of JAVA SE8New Features of JAVA SE8
New Features of JAVA SE8
 
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
 
Automatic Migration of Legacy Java Method Implementations to Interfaces
Automatic Migration of Legacy Java Method Implementations to InterfacesAutomatic Migration of Legacy Java Method Implementations to Interfaces
Automatic Migration of Legacy Java Method Implementations to Interfaces
 
Java 8 - Project Lambda
Java 8 - Project LambdaJava 8 - Project Lambda
Java 8 - Project Lambda
 
Java 8
Java 8Java 8
Java 8
 
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
 
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
 
Colloquium Report
Colloquium ReportColloquium Report
Colloquium Report
 
Defaultification Refactoring: A Tool for Automatically Converting Java Method...
Defaultification Refactoring: A Tool for Automatically Converting Java Method...Defaultification Refactoring: A Tool for Automatically Converting Java Method...
Defaultification Refactoring: A Tool for Automatically Converting Java Method...
 
14274730 (1).ppt
14274730 (1).ppt14274730 (1).ppt
14274730 (1).ppt
 
Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...
Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...
Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...
 
java.pptx
java.pptxjava.pptx
java.pptx
 
Java
JavaJava
Java
 
Java 9 features
Java 9 featuresJava 9 features
Java 9 features
 
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
 
Automated Refactoring of Legacy Java Software to Default Methods Talk at GMU
Automated Refactoring of Legacy Java Software to Default Methods Talk at GMUAutomated Refactoring of Legacy Java Software to Default Methods Talk at GMU
Automated Refactoring of Legacy Java Software to Default Methods Talk at GMU
 
Java For beginners and CSIT and IT students
Java  For beginners and CSIT and IT studentsJava  For beginners and CSIT and IT students
Java For beginners and CSIT and IT students
 

Mais de Rohit Verma

Containerization and version control system
Containerization and version control systemContainerization and version control system
Containerization and version control systemRohit Verma
 
Library manaementreport1
Library manaementreport1Library manaementreport1
Library manaementreport1Rohit Verma
 
Blockchain tutorial
Blockchain tutorial Blockchain tutorial
Blockchain tutorial Rohit Verma
 
blockchain unit 3
blockchain unit 3blockchain unit 3
blockchain unit 3Rohit Verma
 
Use case of block chain unit 4 AKTU
Use case of block chain unit 4 AKTUUse case of block chain unit 4 AKTU
Use case of block chain unit 4 AKTURohit Verma
 
Hyper ledger febric
Hyper ledger febricHyper ledger febric
Hyper ledger febricRohit Verma
 

Mais de Rohit Verma (7)

Containerization and version control system
Containerization and version control systemContainerization and version control system
Containerization and version control system
 
Library manaementreport1
Library manaementreport1Library manaementreport1
Library manaementreport1
 
Blockchain tutorial
Blockchain tutorial Blockchain tutorial
Blockchain tutorial
 
blockchain unit 3
blockchain unit 3blockchain unit 3
blockchain unit 3
 
Use case of block chain unit 4 AKTU
Use case of block chain unit 4 AKTUUse case of block chain unit 4 AKTU
Use case of block chain unit 4 AKTU
 
Hyper ledger febric
Hyper ledger febricHyper ledger febric
Hyper ledger febric
 
Python ppt
Python pptPython ppt
Python ppt
 

Último

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 

Último (20)

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

java 8 new features

  • 2. CONTENT • Introduction • Lambda Expression • Functional Interfaces • Default methods • Predicates • Functions • Double colon operator • Stream API • Date and Time API • Project
  • 3. Introduction • java 7 – July 28th 2011 • Java 8 - March 18th 2014 • Java 9 - September 22nd 2016 • Java 10 – 2018 • After Java 1.5version, Java 8 is the next major version. Before Java 8, sun people gave importance only for objects but in 1.8version oracle people gave the importance for functional aspects of programming to bring its benefits to Java.ie it doesn’t mean Java is functional oriented programming language
  • 4. Lambda Expression • Lambda Expression is just an anonymous (nameless) function. That means the function which doesn’t have the name, return type and access modifiers. public void m1() { sop(“hello”); } () ->{ sop(“hello”); }
  • 5. Functional Interfaces • If an interface contain only one abstract method, such type of interfaces are called functional interfaces and the method is called functional method or single abstract method (SAM) • Ex-> • 1) Runnable -> It contains only run() method • 2) Comparable ->It contains only compareTo() method • 3) ActionListener -> It contains only actionPerformed() • 4) Callable -> It contains only call() method interface Interf { public abstract void m1(); default void m2() { System.out.println (“hello”); } } @Functional Interface Interface Interf { public void m1(); }
  • 6. Default methods • Until 1.7 version onwards inside interface we can take only public abstract methods and public static final variables • But from 1.8 version onwards in addition to these, we can declare default concrete methods also inside interface, which are also known as defender methods. default void m1() { System.out.println (“Default Method”); } • Interface default methods are by-default available to all implementation classes. Based on requirement implementation class can use these default methods directly or can override
  • 7. Predicates • A predicate is a function with a single argument and returns boolean value. • To implement predicate functions in Java, Oracle people introduced Predicate interface in 1.8 version (i.e.,Predicate) • Predicate interface present in Java.util.function package. • public boolean test(Integer I) { if (I >10) { return true; } else { return false; } } With predicate predicate p = I ->(I >10); System.out.println (p.test(100)); true System.out.println (p.test(7)); false
  • 8. Functions • Functions are exactly same as predicates except that functions can return any type of result but function should (can) return only one value and that value can be any type as per our requirement • To implement functions oracle people introduced Function interface in 1.8version. • interface function(T,R) { • public R apply(T t); • }
  • 9. Double colon operator • Functional Interface method can be mapped to our specified method by using :: (double colon) operator. This is called method reference. • Our specified method can be either static method or instance method Syntax: if our specified method is static method Classname::methodName if the method is instance method Objref::methodName
  • 10. Stream API • To process objects of the collection, in 1.8 version Streams concept introduced. • java.util streams meant for processing objects from the collection. I and Java.io streams meant for processing binary and character data with respect to file. • We can create a stream object to the collection by using stream() method of Collection interface. stream() method is a default method added to the Collection in 1.8 version. • default Stream stream() • Stream s = c.stream(); • Stream is an interface present in java.util.stream. Once we got the stream, by using that we can process objects of that collection. We can process the objects in the following 2 phases • Configuration • Mapping
  • 11. Date and Time API • Joda-Time API • Until Java 1.7version the classes present in Java.util package to handle Date and Time (like Date, Calendar, TimeZoneetc) are not up to the mark with respect to convenience and performance. • To overcome this problem in the 1.8version oracle people introduced Joda-Time API. This API developed by joda.org and available in Java in the form of Java.time package.