SlideShare a Scribd company logo
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
Ad

More Related Content

What's hot (20)

Java 8 presentation
Java 8 presentationJava 8 presentation
Java 8 presentation
Van Huong
 
Java 8 Lambda Expressions & Streams
Java 8 Lambda Expressions & StreamsJava 8 Lambda Expressions & Streams
Java 8 Lambda Expressions & Streams
NewCircle Training
 
Core java complete ppt(note)
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)
arvind pandey
 
Introduction to Java 8
Introduction to Java 8Introduction to Java 8
Introduction to Java 8
Knoldus Inc.
 
JPA and Hibernate
JPA and HibernateJPA and Hibernate
JPA and Hibernate
elliando dias
 
Java 8 - Features Overview
Java 8 - Features OverviewJava 8 - Features Overview
Java 8 - Features Overview
Sergii Stets
 
Java Persistence API (JPA) Step By Step
Java Persistence API (JPA) Step By StepJava Persistence API (JPA) Step By Step
Java Persistence API (JPA) Step By Step
Guo Albert
 
Wrapper class
Wrapper classWrapper class
Wrapper class
kamal kotecha
 
Core java concepts
Core java  conceptsCore java  concepts
Core java concepts
Ram132
 
Java - Collections framework
Java - Collections frameworkJava - Collections framework
Java - Collections framework
Riccardo Cardin
 
Files in java
Files in javaFiles in java
Files in java
Muthukumaran Subramanian
 
Spring Boot
Spring BootSpring Boot
Spring Boot
Jiayun Zhou
 
Introduction to java 8 stream api
Introduction to java 8 stream apiIntroduction to java 8 stream api
Introduction to java 8 stream api
Vladislav sidlyarevich
 
java interface and packages
java interface and packagesjava interface and packages
java interface and packages
VINOTH R
 
Java: GUI
Java: GUIJava: GUI
Java: GUI
Tareq Hasan
 
Collections - Lists, Sets
Collections - Lists, Sets Collections - Lists, Sets
Collections - Lists, Sets
Hitesh-Java
 
Strings in Java
Strings in JavaStrings in Java
Strings in Java
Abhilash Nair
 
Java Collections
Java CollectionsJava Collections
Java Collections
parag
 
Collections In Java
Collections In JavaCollections In Java
Collections In Java
Binoj T E
 
Collection Framework in java
Collection Framework in javaCollection Framework in java
Collection Framework in java
CPD INDIA
 
Java 8 presentation
Java 8 presentationJava 8 presentation
Java 8 presentation
Van Huong
 
Java 8 Lambda Expressions & Streams
Java 8 Lambda Expressions & StreamsJava 8 Lambda Expressions & Streams
Java 8 Lambda Expressions & Streams
NewCircle Training
 
Core java complete ppt(note)
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)
arvind pandey
 
Introduction to Java 8
Introduction to Java 8Introduction to Java 8
Introduction to Java 8
Knoldus Inc.
 
Java 8 - Features Overview
Java 8 - Features OverviewJava 8 - Features Overview
Java 8 - Features Overview
Sergii Stets
 
Java Persistence API (JPA) Step By Step
Java Persistence API (JPA) Step By StepJava Persistence API (JPA) Step By Step
Java Persistence API (JPA) Step By Step
Guo Albert
 
Core java concepts
Core java  conceptsCore java  concepts
Core java concepts
Ram132
 
Java - Collections framework
Java - Collections frameworkJava - Collections framework
Java - Collections framework
Riccardo Cardin
 
java interface and packages
java interface and packagesjava interface and packages
java interface and packages
VINOTH R
 
Collections - Lists, Sets
Collections - Lists, Sets Collections - Lists, Sets
Collections - Lists, Sets
Hitesh-Java
 
Java Collections
Java CollectionsJava Collections
Java Collections
parag
 
Collections In Java
Collections In JavaCollections In Java
Collections In Java
Binoj T E
 
Collection Framework in java
Collection Framework in javaCollection Framework in java
Collection Framework in java
CPD INDIA
 

Similar to java 8 new features (20)

Java 8 Interview Questions and Answers PDF By ScholarHat.pdf
Java 8 Interview Questions and Answers PDF By ScholarHat.pdfJava 8 Interview Questions and Answers PDF By ScholarHat.pdf
Java 8 Interview Questions and Answers PDF By ScholarHat.pdf
Scholarhat
 
New Features of JAVA SE8
New Features of JAVA SE8New Features of JAVA SE8
New Features of JAVA SE8
Dinesh Pathak
 
Java 8 new features or the ones you might actually use
Java 8 new features or the ones you might actually useJava 8 new features or the ones you might actually use
Java 8 new features or the ones you might actually use
Sharon Rozinsky
 
Intro to java 8
Intro to java 8Intro to java 8
Intro to java 8
John Godoi
 
Java 8 - An Overview
Java 8 - An OverviewJava 8 - An Overview
Java 8 - An Overview
Indrajit Das
 
14274730 (1).ppt
14274730 (1).ppt14274730 (1).ppt
14274730 (1).ppt
aptechaligarh
 
java150929145120-lva1-app6892 (2).pptx
java150929145120-lva1-app6892 (2).pptxjava150929145120-lva1-app6892 (2).pptx
java150929145120-lva1-app6892 (2).pptx
BruceLee275640
 
Java 8 Intro - Core Features
Java 8 Intro - Core FeaturesJava 8 Intro - Core Features
Java 8 Intro - Core Features
GlobalLogic Ukraine
 
Java8: what's new and what's hot
Java8: what's new and what's hotJava8: what's new and what's hot
Java8: what's new and what's hot
Sergii Maliarov
 
Java 8 new features
Java 8 new featuresJava 8 new features
Java 8 new features
Aniket Thakur
 
A brief tour of modern Java
A brief tour of modern JavaA brief tour of modern Java
A brief tour of modern Java
Sina Madani
 
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
Syed Awais Mazhar Bukhari
 
The Road to Lambda - Mike Duigou
The Road to Lambda - Mike DuigouThe Road to Lambda - Mike Duigou
The Road to Lambda - Mike Duigou
jaxconf
 
Java SE 8 - New Features
Java SE 8 - New FeaturesJava SE 8 - New Features
Java SE 8 - New Features
Naveen Hegde
 
Java 8 Feature Preview
Java 8 Feature PreviewJava 8 Feature Preview
Java 8 Feature Preview
Jim Bethancourt
 
Java 8 features
Java 8 featuresJava 8 features
Java 8 features
Maýur Chourasiya
 
What’s new in java 8
What’s new in java 8What’s new in java 8
What’s new in java 8
Rajmahendra Hegde
 
Java 8 - Project Lambda
Java 8 - Project LambdaJava 8 - Project Lambda
Java 8 - Project Lambda
Rahman USTA
 
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
Neil Brown
 
Software Uni Conf October 2014
Software Uni Conf October 2014Software Uni Conf October 2014
Software Uni Conf October 2014
Nayden Gochev
 
Java 8 Interview Questions and Answers PDF By ScholarHat.pdf
Java 8 Interview Questions and Answers PDF By ScholarHat.pdfJava 8 Interview Questions and Answers PDF By ScholarHat.pdf
Java 8 Interview Questions and Answers PDF By ScholarHat.pdf
Scholarhat
 
New Features of JAVA SE8
New Features of JAVA SE8New Features of JAVA SE8
New Features of JAVA SE8
Dinesh Pathak
 
Java 8 new features or the ones you might actually use
Java 8 new features or the ones you might actually useJava 8 new features or the ones you might actually use
Java 8 new features or the ones you might actually use
Sharon Rozinsky
 
Intro to java 8
Intro to java 8Intro to java 8
Intro to java 8
John Godoi
 
Java 8 - An Overview
Java 8 - An OverviewJava 8 - An Overview
Java 8 - An Overview
Indrajit Das
 
java150929145120-lva1-app6892 (2).pptx
java150929145120-lva1-app6892 (2).pptxjava150929145120-lva1-app6892 (2).pptx
java150929145120-lva1-app6892 (2).pptx
BruceLee275640
 
Java8: what's new and what's hot
Java8: what's new and what's hotJava8: what's new and what's hot
Java8: what's new and what's hot
Sergii Maliarov
 
A brief tour of modern Java
A brief tour of modern JavaA brief tour of modern Java
A brief tour of modern Java
Sina Madani
 
The Road to Lambda - Mike Duigou
The Road to Lambda - Mike DuigouThe Road to Lambda - Mike Duigou
The Road to Lambda - Mike Duigou
jaxconf
 
Java SE 8 - New Features
Java SE 8 - New FeaturesJava SE 8 - New Features
Java SE 8 - New Features
Naveen Hegde
 
Java 8 - Project Lambda
Java 8 - Project LambdaJava 8 - Project Lambda
Java 8 - Project Lambda
Rahman USTA
 
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
Neil Brown
 
Software Uni Conf October 2014
Software Uni Conf October 2014Software Uni Conf October 2014
Software Uni Conf October 2014
Nayden Gochev
 
Ad

More from Rohit Verma (7)

Containerization and version control system
Containerization and version control systemContainerization and version control system
Containerization and version control system
Rohit Verma
 
Library manaementreport1
Library manaementreport1Library manaementreport1
Library manaementreport1
Rohit Verma
 
Blockchain tutorial
Blockchain tutorial Blockchain tutorial
Blockchain tutorial
Rohit Verma
 
blockchain unit 3
blockchain unit 3blockchain unit 3
blockchain unit 3
Rohit 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 AKTU
Rohit Verma
 
Hyper ledger febric
Hyper ledger febricHyper ledger febric
Hyper ledger febric
Rohit Verma
 
Python ppt
Python pptPython ppt
Python ppt
Rohit Verma
 
Containerization and version control system
Containerization and version control systemContainerization and version control system
Containerization and version control system
Rohit Verma
 
Library manaementreport1
Library manaementreport1Library manaementreport1
Library manaementreport1
Rohit Verma
 
Blockchain tutorial
Blockchain tutorial Blockchain tutorial
Blockchain tutorial
Rohit Verma
 
blockchain unit 3
blockchain unit 3blockchain unit 3
blockchain unit 3
Rohit 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 AKTU
Rohit Verma
 
Hyper ledger febric
Hyper ledger febricHyper ledger febric
Hyper ledger febric
Rohit Verma
 
Ad

Recently uploaded (20)

Best 10 Free AI Character Chat Platforms
Best 10 Free AI Character Chat PlatformsBest 10 Free AI Character Chat Platforms
Best 10 Free AI Character Chat Platforms
Soulmaite
 
Developing Product-Behavior Fit: UX Research in Product Development by Krysta...
Developing Product-Behavior Fit: UX Research in Product Development by Krysta...Developing Product-Behavior Fit: UX Research in Product Development by Krysta...
Developing Product-Behavior Fit: UX Research in Product Development by Krysta...
UXPA Boston
 
AI needs Hybrid Cloud - TEC conference 2025.pptx
AI needs Hybrid Cloud - TEC conference 2025.pptxAI needs Hybrid Cloud - TEC conference 2025.pptx
AI needs Hybrid Cloud - TEC conference 2025.pptx
Shikha Srivastava
 
Breaking it Down: Microservices Architecture for PHP Developers
Breaking it Down: Microservices Architecture for PHP DevelopersBreaking it Down: Microservices Architecture for PHP Developers
Breaking it Down: Microservices Architecture for PHP Developers
pmeth1
 
RFID in Supply chain management and logistics.pdf
RFID in Supply chain management and logistics.pdfRFID in Supply chain management and logistics.pdf
RFID in Supply chain management and logistics.pdf
EnCStore Private Limited
 
Shoehorning dependency injection into a FP language, what does it take?
Shoehorning dependency injection into a FP language, what does it take?Shoehorning dependency injection into a FP language, what does it take?
Shoehorning dependency injection into a FP language, what does it take?
Eric Torreborre
 
Is Your QA Team Still Working in Silos? Here's What to Do.
Is Your QA Team Still Working in Silos? Here's What to Do.Is Your QA Team Still Working in Silos? Here's What to Do.
Is Your QA Team Still Working in Silos? Here's What to Do.
marketing943205
 
Multi-Agent AI Systems: Architectures & Communication (MCP and A2A)
Multi-Agent AI Systems: Architectures & Communication (MCP and A2A)Multi-Agent AI Systems: Architectures & Communication (MCP and A2A)
Multi-Agent AI Systems: Architectures & Communication (MCP and A2A)
HusseinMalikMammadli
 
論文紹介:"InfLoRA: Interference-Free Low-Rank Adaptation for Continual Learning" ...
論文紹介:"InfLoRA: Interference-Free Low-Rank Adaptation for Continual Learning" ...論文紹介:"InfLoRA: Interference-Free Low-Rank Adaptation for Continual Learning" ...
論文紹介:"InfLoRA: Interference-Free Low-Rank Adaptation for Continual Learning" ...
Toru Tamaki
 
Secondary Storage for a microcontroller system
Secondary Storage for a microcontroller systemSecondary Storage for a microcontroller system
Secondary Storage for a microcontroller system
fizarcse
 
Digital Technologies for Culture, Arts and Heritage: Insights from Interdisci...
Digital Technologies for Culture, Arts and Heritage: Insights from Interdisci...Digital Technologies for Culture, Arts and Heritage: Insights from Interdisci...
Digital Technologies for Culture, Arts and Heritage: Insights from Interdisci...
Vasileios Komianos
 
SQL Database Design For Developers at PhpTek 2025.pptx
SQL Database Design For Developers at PhpTek 2025.pptxSQL Database Design For Developers at PhpTek 2025.pptx
SQL Database Design For Developers at PhpTek 2025.pptx
Scott Keck-Warren
 
Longitudinal Benchmark: A Real-World UX Case Study in Onboarding by Linda Bor...
Longitudinal Benchmark: A Real-World UX Case Study in Onboarding by Linda Bor...Longitudinal Benchmark: A Real-World UX Case Study in Onboarding by Linda Bor...
Longitudinal Benchmark: A Real-World UX Case Study in Onboarding by Linda Bor...
UXPA Boston
 
Accommodating Neurodiverse Users Online (Global Accessibility Awareness Day 2...
Accommodating Neurodiverse Users Online (Global Accessibility Awareness Day 2...Accommodating Neurodiverse Users Online (Global Accessibility Awareness Day 2...
Accommodating Neurodiverse Users Online (Global Accessibility Awareness Day 2...
User Vision
 
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Safe Software
 
AI and Meaningful Work by Pablo Fernández Vallejo
AI and Meaningful Work by Pablo Fernández VallejoAI and Meaningful Work by Pablo Fernández Vallejo
AI and Meaningful Work by Pablo Fernández Vallejo
UXPA Boston
 
Mastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B LandscapeMastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B Landscape
marketing943205
 
Refactoring meta-rauc-community: Cleaner Code, Better Maintenance, More Machines
Refactoring meta-rauc-community: Cleaner Code, Better Maintenance, More MachinesRefactoring meta-rauc-community: Cleaner Code, Better Maintenance, More Machines
Refactoring meta-rauc-community: Cleaner Code, Better Maintenance, More Machines
Leon Anavi
 
machines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdfmachines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdf
AmirStern2
 
UiPath AgentHack - Build the AI agents of tomorrow_Enablement 1.pptx
UiPath AgentHack - Build the AI agents of tomorrow_Enablement 1.pptxUiPath AgentHack - Build the AI agents of tomorrow_Enablement 1.pptx
UiPath AgentHack - Build the AI agents of tomorrow_Enablement 1.pptx
anabulhac
 
Best 10 Free AI Character Chat Platforms
Best 10 Free AI Character Chat PlatformsBest 10 Free AI Character Chat Platforms
Best 10 Free AI Character Chat Platforms
Soulmaite
 
Developing Product-Behavior Fit: UX Research in Product Development by Krysta...
Developing Product-Behavior Fit: UX Research in Product Development by Krysta...Developing Product-Behavior Fit: UX Research in Product Development by Krysta...
Developing Product-Behavior Fit: UX Research in Product Development by Krysta...
UXPA Boston
 
AI needs Hybrid Cloud - TEC conference 2025.pptx
AI needs Hybrid Cloud - TEC conference 2025.pptxAI needs Hybrid Cloud - TEC conference 2025.pptx
AI needs Hybrid Cloud - TEC conference 2025.pptx
Shikha Srivastava
 
Breaking it Down: Microservices Architecture for PHP Developers
Breaking it Down: Microservices Architecture for PHP DevelopersBreaking it Down: Microservices Architecture for PHP Developers
Breaking it Down: Microservices Architecture for PHP Developers
pmeth1
 
RFID in Supply chain management and logistics.pdf
RFID in Supply chain management and logistics.pdfRFID in Supply chain management and logistics.pdf
RFID in Supply chain management and logistics.pdf
EnCStore Private Limited
 
Shoehorning dependency injection into a FP language, what does it take?
Shoehorning dependency injection into a FP language, what does it take?Shoehorning dependency injection into a FP language, what does it take?
Shoehorning dependency injection into a FP language, what does it take?
Eric Torreborre
 
Is Your QA Team Still Working in Silos? Here's What to Do.
Is Your QA Team Still Working in Silos? Here's What to Do.Is Your QA Team Still Working in Silos? Here's What to Do.
Is Your QA Team Still Working in Silos? Here's What to Do.
marketing943205
 
Multi-Agent AI Systems: Architectures & Communication (MCP and A2A)
Multi-Agent AI Systems: Architectures & Communication (MCP and A2A)Multi-Agent AI Systems: Architectures & Communication (MCP and A2A)
Multi-Agent AI Systems: Architectures & Communication (MCP and A2A)
HusseinMalikMammadli
 
論文紹介:"InfLoRA: Interference-Free Low-Rank Adaptation for Continual Learning" ...
論文紹介:"InfLoRA: Interference-Free Low-Rank Adaptation for Continual Learning" ...論文紹介:"InfLoRA: Interference-Free Low-Rank Adaptation for Continual Learning" ...
論文紹介:"InfLoRA: Interference-Free Low-Rank Adaptation for Continual Learning" ...
Toru Tamaki
 
Secondary Storage for a microcontroller system
Secondary Storage for a microcontroller systemSecondary Storage for a microcontroller system
Secondary Storage for a microcontroller system
fizarcse
 
Digital Technologies for Culture, Arts and Heritage: Insights from Interdisci...
Digital Technologies for Culture, Arts and Heritage: Insights from Interdisci...Digital Technologies for Culture, Arts and Heritage: Insights from Interdisci...
Digital Technologies for Culture, Arts and Heritage: Insights from Interdisci...
Vasileios Komianos
 
SQL Database Design For Developers at PhpTek 2025.pptx
SQL Database Design For Developers at PhpTek 2025.pptxSQL Database Design For Developers at PhpTek 2025.pptx
SQL Database Design For Developers at PhpTek 2025.pptx
Scott Keck-Warren
 
Longitudinal Benchmark: A Real-World UX Case Study in Onboarding by Linda Bor...
Longitudinal Benchmark: A Real-World UX Case Study in Onboarding by Linda Bor...Longitudinal Benchmark: A Real-World UX Case Study in Onboarding by Linda Bor...
Longitudinal Benchmark: A Real-World UX Case Study in Onboarding by Linda Bor...
UXPA Boston
 
Accommodating Neurodiverse Users Online (Global Accessibility Awareness Day 2...
Accommodating Neurodiverse Users Online (Global Accessibility Awareness Day 2...Accommodating Neurodiverse Users Online (Global Accessibility Awareness Day 2...
Accommodating Neurodiverse Users Online (Global Accessibility Awareness Day 2...
User Vision
 
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Safe Software
 
AI and Meaningful Work by Pablo Fernández Vallejo
AI and Meaningful Work by Pablo Fernández VallejoAI and Meaningful Work by Pablo Fernández Vallejo
AI and Meaningful Work by Pablo Fernández Vallejo
UXPA Boston
 
Mastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B LandscapeMastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B Landscape
marketing943205
 
Refactoring meta-rauc-community: Cleaner Code, Better Maintenance, More Machines
Refactoring meta-rauc-community: Cleaner Code, Better Maintenance, More MachinesRefactoring meta-rauc-community: Cleaner Code, Better Maintenance, More Machines
Refactoring meta-rauc-community: Cleaner Code, Better Maintenance, More Machines
Leon Anavi
 
machines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdfmachines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdf
AmirStern2
 
UiPath AgentHack - Build the AI agents of tomorrow_Enablement 1.pptx
UiPath AgentHack - Build the AI agents of tomorrow_Enablement 1.pptxUiPath AgentHack - Build the AI agents of tomorrow_Enablement 1.pptx
UiPath AgentHack - Build the AI agents of tomorrow_Enablement 1.pptx
anabulhac
 

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.
  翻译: