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

More Related Content

PPTX
Software Uni Conf October 2014
PPTX
Java- Updates in java8-Mazenet solution
PPTX
New Features of JAVA SE8
PPTX
Introduction of Java 8 with emphasis on Lambda Expressions and Streams
PDF
Automatic Migration of Legacy Java Method Implementations to Interfaces
PDF
Java 8 - Project Lambda
PPTX
PPTX
A-Brief-Introduction-To-JAVA8_By_Srimanta_Sahu
Software Uni Conf October 2014
Java- Updates in java8-Mazenet solution
New Features of JAVA SE8
Introduction of Java 8 with emphasis on Lambda Expressions and Streams
Automatic Migration of Legacy Java Method Implementations to Interfaces
Java 8 - Project Lambda
A-Brief-Introduction-To-JAVA8_By_Srimanta_Sahu

Similar to Stream Api.pdf (20)

PPTX
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
DOCX
Colloquium Report
PDF
Defaultification Refactoring: A Tool for Automatically Converting Java Method...
PPT
14274730 (1).ppt
PDF
Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...
PDF
Java8 features
PPTX
PDF
Java 8 features
PPTX
2. Introduction to Java for engineering stud
PPTX
PPTX
Java 9 features
PPTX
Insight into java 1.8, OOP VS FP
PPTX
Java 8
PPTX
brief introduction to core java programming.pptx
PDF
Automated Refactoring of Legacy Java Software to Default Methods Talk at GMU
PPTX
Java For beginners and CSIT and IT students
PPT
JAVA_BASICS_Data_abstraction_encapsulation.ppt
PDF
PPTX
1_JavIntro
PPTX
object oriented programming unit one ppt
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Colloquium Report
Defaultification Refactoring: A Tool for Automatically Converting Java Method...
14274730 (1).ppt
Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...
Java8 features
Java 8 features
2. Introduction to Java for engineering stud
Java 9 features
Insight into java 1.8, OOP VS FP
Java 8
brief introduction to core java programming.pptx
Automated Refactoring of Legacy Java Software to Default Methods Talk at GMU
Java For beginners and CSIT and IT students
JAVA_BASICS_Data_abstraction_encapsulation.ppt
1_JavIntro
object oriented programming unit one ppt
Ad

Recently uploaded (20)

PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Encapsulation theory and applications.pdf
PPT
Teaching material agriculture food technology
PDF
Approach and Philosophy of On baking technology
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Spectroscopy.pptx food analysis technology
PPTX
Cloud computing and distributed systems.
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Electronic commerce courselecture one. Pdf
Understanding_Digital_Forensics_Presentation.pptx
Encapsulation theory and applications.pdf
Teaching material agriculture food technology
Approach and Philosophy of On baking technology
Reach Out and Touch Someone: Haptics and Empathic Computing
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Spectroscopy.pptx food analysis technology
Cloud computing and distributed systems.
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
Chapter 3 Spatial Domain Image Processing.pdf
Spectral efficient network and resource selection model in 5G networks
Mobile App Security Testing_ A Comprehensive Guide.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
Per capita expenditure prediction using model stacking based on satellite ima...
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Encapsulation_ Review paper, used for researhc scholars
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Electronic commerce courselecture one. Pdf
Ad

Stream Api.pdf

  • 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.