SlideShare ist ein Scribd-Unternehmen logo
1 von 18
Presentation on
New Features in Java 8
Presented By
Dinesh Kumar Pathak
Introduction of Java:
Java is a programming language created by James
Gosling from Sun Microsystems (Sun) in 1991. The
target of Java is to write a program once and then run
this pro
The current version of Java is Java 1.8 which is also
known as Java 8.
The Java language was designed with the following
properties:
1. Platform independent
2. Object-orientated programming language
3. Interpreted and compiled language
4. Automatic memory management
Oops Concept:
Abstraction
Encapsulation
Polymorphism
Inheritance
Dynamic Binding
New Features in Java8:
forEach() method in Iterable interface.
default and static methods in interface.
Functional interfaces and lambda expression.
Java Stream API for Bulk Data Operation on
Collection.
Java Time API.
Collection API improvements.
Concurrency API improvements.
Java IO improvements.
forEach() method in Iterable interface:
Whenever we need to traverse through a Collection,
we need to create an Iterator whose whole purpose is
to iterate over
Java 8 has introduced forEach method
in java.lang.Iterable interface so that while writing
code we focus on logic only.
default and static methods in interface:
If you read forEach method details carefully, you will
notice that it’s defined in Iterable interface but we
know that interfaces can’t have method body.
 From Java 8, interfaces are enhanced to have method
with implementation. We can
use default and static keyword to create interfaces
with method implementation.
Static methods, by definition, are not abstract .
default void forEach(ClassName<? super T> action) {
}
Lambda Expression:
 Implement Functional Programming
Lambda expressions provide anonymous function types to
Java.
– Replace use of anonymous inner classes.
– Provide more functional style of programming in
Java.
doSomething(new DoStuff() {
public boolean isGood(int value) {
return value == 42;
}
});
doSomething(answer -> answer == 42);
Lambda Expressions in GUI
Applications:
 To process events in a graphical user interface (GUI) application, such as
keyboard actions, mouse actions, and scroll actions, you typically create
event handlers, which usually involves implementing a particular interface.
Often, event handler interfaces are functional interfaces; they tend to have
only one method.
btn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
System.out.println("Hello World!");
}
});
btn.setOnAction(
event -> System.out.println("Hello World!")
);
Functional Interface:
Single Abstract Method (SAM) type
A functional interface is an interface that has one
abstract method.
– Represents a single function contract.
– Doesn’t mean it only has one method .
@FunctionalInterface annotation
– Helps ensure the functional interface
contract is honoured
– Compiler error if not a SAM
Extension Methods:
Bringing Multiple Inheritance (of Functionality) to Java
 Provide a mechanism to add new methods to existing
interfaces
– Without breaking backwards compatibility
– Gives Java multiple inheritance of behavior, as well as
types (but not state!)
public interface Set extends Collection {
public int size();
... // The rest of the existing Set methods
public T reduce(Reducer r) default Collections.setReducer;
}
Java Stream API:
A new java.util.stream has been added in Java 8 to
perform filter/map/reduce like operations with the
collection.
 This is one of the best feature because we work a lot with
Collections and usually with Big Data, we need to filter out
them based on some conditions.
Collection interface has been extended
with stream() and parallelStream() default methods to get
the Stream for sequential and parallel execution.
parallel processing will be very helpful while working with
huge collections.
Java Time API:
It has always been hard to work with Date, Time and
Time Zones in java. There was no standard approach
or API in java for date and time in Java.
One of the nice addition in Java 8 is the java.time
package that will streamline the process of working
with time in java.
One of the useful class is DateTimeFormatter for
converting date time objects to strings.
Collection API improvements:
Iterator default method
forEachRemaining(ClassName object) to perform the
given action for each remaining element until all elements
have been processed or the action throws an exception.
Collection default method removeIf(Predicate filter) to
remove all of the elements of this collection that satisfy the
given predicate.
Collection spliterator() method returning Spliterator
instance that can be used to traverse elements sequentially
or parallel.
Map replaceAll(), compute(), merge() methods.
Performance Improvement for HashMap
class with Key Collisions, how?
in case of collision till Java 7 it used to store values in
linked list and the search order for link list is O(n), but
in java 8 it forms binary tree (O(log(n))) instead of
linked list. This makes search faster, this would be
useful in case of billions of records getting collide for
same hash key.
Concurrency API improvements:
Files.list(Path dir) that returns a lazily populated
Stream, the elements of which are the entries in the
directory.
Files.lines(Path path) that reads all lines from a file as
a Stream.
Files.find() that returns a Stream that is lazily
populated with Path by searching for files in a file tree
rooted at a given starting file.
BufferedReader.lines() that return a Stream, the
elements of which are lines read from this
BufferedReader.
Nashorn JavaScript Engine:
Lightweight, high-performance JavaScript engine.
– Integrated into JRE .
Use existing javax.script API.
 New command-line tool, jjs, to run JavaScript.
It can run scripts as JavaFX applications
Native javascript arrays are untyped. Nashorn enables
you to use typed java arrays in javascript.
Some Other Features:
Comparator interface has been extended with a lot of
default and static methods for natural ordering,
reverse order etc.
min(), max() and sum() methods in Integer, Long and
Double wrapper classes.
logicalAnd(), logicalOr() and logicalXor() methods in
Boolean class.
JDBC-ODBC Bridge has been removed.
New Features in Java 8
end of presentation
Thank you

Weitere ähnliche Inhalte

Was ist angesagt?

The Dark Side Of Lambda Expressions in Java 8
The Dark Side Of Lambda Expressions in Java 8The Dark Side Of Lambda Expressions in Java 8
The Dark Side Of Lambda Expressions in Java 8Takipi
 
Java 8 Lambda Expressions & Streams
Java 8 Lambda Expressions & StreamsJava 8 Lambda Expressions & Streams
Java 8 Lambda Expressions & StreamsNewCircle Training
 
Lambda Expressions in Java 8
Lambda Expressions in Java 8Lambda Expressions in Java 8
Lambda Expressions in Java 8icarter09
 
Functional programming with Java 8
Functional programming with Java 8Functional programming with Java 8
Functional programming with Java 8LivePerson
 
Java- Updates in java8-Mazenet solution
Java- Updates in java8-Mazenet solutionJava- Updates in java8-Mazenet solution
Java- Updates in java8-Mazenet solutionMazenetsolution
 
Functional programming in java 8 by harmeet singh
Functional programming in java 8 by harmeet singhFunctional programming in java 8 by harmeet singh
Functional programming in java 8 by harmeet singhHarmeet Singh(Taara)
 
Java 8 Streams And Common Operations By Harmeet Singh(Taara)
Java 8 Streams And Common Operations By Harmeet Singh(Taara)Java 8 Streams And Common Operations By Harmeet Singh(Taara)
Java 8 Streams And Common Operations By Harmeet Singh(Taara)Harmeet Singh(Taara)
 
Programming with Lambda Expressions in Java
Programming with Lambda Expressions in Java Programming with Lambda Expressions in Java
Programming with Lambda Expressions in Java langer4711
 
Functional programming with Java 8
Functional programming with Java 8Functional programming with Java 8
Functional programming with Java 8Talha Ocakçı
 
New Features Of JDK 7
New Features Of JDK 7New Features Of JDK 7
New Features Of JDK 7Deniz Oguz
 
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
 
Software Uni Conf October 2014
Software Uni Conf October 2014Software Uni Conf October 2014
Software Uni Conf October 2014Nayden Gochev
 
Eclipse Day India 2015 - Java 8 Overview
Eclipse Day India 2015 - Java 8 OverviewEclipse Day India 2015 - Java 8 Overview
Eclipse Day India 2015 - Java 8 OverviewEclipse Day India
 

Was ist angesagt? (20)

Java 8 lambda
Java 8 lambdaJava 8 lambda
Java 8 lambda
 
Java 8 Features
Java 8 FeaturesJava 8 Features
Java 8 Features
 
Smart Migration to JDK 8
Smart Migration to JDK 8Smart Migration to JDK 8
Smart Migration to JDK 8
 
The Dark Side Of Lambda Expressions in Java 8
The Dark Side Of Lambda Expressions in Java 8The Dark Side Of Lambda Expressions in Java 8
The Dark Side Of Lambda Expressions in Java 8
 
Java 8 Lambda Expressions & Streams
Java 8 Lambda Expressions & StreamsJava 8 Lambda Expressions & Streams
Java 8 Lambda Expressions & Streams
 
Lambda Expressions in Java 8
Lambda Expressions in Java 8Lambda Expressions in Java 8
Lambda Expressions in Java 8
 
Java8
Java8Java8
Java8
 
Functional programming with Java 8
Functional programming with Java 8Functional programming with Java 8
Functional programming with Java 8
 
Java- Updates in java8-Mazenet solution
Java- Updates in java8-Mazenet solutionJava- Updates in java8-Mazenet solution
Java- Updates in java8-Mazenet solution
 
Functional programming in java 8 by harmeet singh
Functional programming in java 8 by harmeet singhFunctional programming in java 8 by harmeet singh
Functional programming in java 8 by harmeet singh
 
Java 8 Streams And Common Operations By Harmeet Singh(Taara)
Java 8 Streams And Common Operations By Harmeet Singh(Taara)Java 8 Streams And Common Operations By Harmeet Singh(Taara)
Java 8 Streams And Common Operations By Harmeet Singh(Taara)
 
Introduction to new features in java 8
Introduction to new features in java 8Introduction to new features in java 8
Introduction to new features in java 8
 
Java 8 Features
Java 8 FeaturesJava 8 Features
Java 8 Features
 
Programming with Lambda Expressions in Java
Programming with Lambda Expressions in Java Programming with Lambda Expressions in Java
Programming with Lambda Expressions in Java
 
Java 8
Java 8Java 8
Java 8
 
Functional programming with Java 8
Functional programming with Java 8Functional programming with Java 8
Functional programming with Java 8
 
New Features Of JDK 7
New Features Of JDK 7New Features Of JDK 7
New Features Of JDK 7
 
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
 
Software Uni Conf October 2014
Software Uni Conf October 2014Software Uni Conf October 2014
Software Uni Conf October 2014
 
Eclipse Day India 2015 - Java 8 Overview
Eclipse Day India 2015 - Java 8 OverviewEclipse Day India 2015 - Java 8 Overview
Eclipse Day India 2015 - Java 8 Overview
 

Ähnlich wie Java 8 New Features Presentation

Ähnlich wie Java 8 New Features Presentation (20)

Colloquium Report
Colloquium ReportColloquium Report
Colloquium Report
 
Java 8 Overview
Java 8 OverviewJava 8 Overview
Java 8 Overview
 
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
 
whats new in java 8
whats new in java 8 whats new in java 8
whats new in java 8
 
Basic java part_ii
Basic java part_iiBasic java part_ii
Basic java part_ii
 
Example Of Import Java
Example Of Import JavaExample Of Import Java
Example Of Import Java
 
Using Java 8 on Android
Using Java 8 on AndroidUsing Java 8 on Android
Using Java 8 on Android
 
Stream Api.pdf
Stream Api.pdfStream Api.pdf
Stream Api.pdf
 
Java 7 & 8
Java 7 & 8Java 7 & 8
Java 7 & 8
 
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 - An Overview
Java 8 - An OverviewJava 8 - An Overview
Java 8 - An Overview
 
Java 8-revealed
Java 8-revealedJava 8-revealed
Java 8-revealed
 
Java1
Java1Java1
Java1
 
Java
Java Java
Java
 
Java SE 8 & EE 7 Launch
Java SE 8 & EE 7 LaunchJava SE 8 & EE 7 Launch
Java SE 8 & EE 7 Launch
 
Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009
 
Java 8 features
Java 8 featuresJava 8 features
Java 8 features
 
What is Java Technology (An introduction with comparision of .net coding)
What is Java Technology (An introduction with comparision of .net coding)What is Java Technology (An introduction with comparision of .net coding)
What is Java Technology (An introduction with comparision of .net coding)
 
Java 3 rd sem. 2012 aug.ASSIGNMENT
Java 3 rd sem. 2012 aug.ASSIGNMENTJava 3 rd sem. 2012 aug.ASSIGNMENT
Java 3 rd sem. 2012 aug.ASSIGNMENT
 
14274730 (1).ppt
14274730 (1).ppt14274730 (1).ppt
14274730 (1).ppt
 

Kürzlich hochgeladen

BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...Pooja Nehwal
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 

Kürzlich hochgeladen (20)

BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 

Java 8 New Features Presentation

  • 1. Presentation on New Features in Java 8 Presented By Dinesh Kumar Pathak
  • 2. Introduction of Java: Java is a programming language created by James Gosling from Sun Microsystems (Sun) in 1991. The target of Java is to write a program once and then run this pro The current version of Java is Java 1.8 which is also known as Java 8. The Java language was designed with the following properties: 1. Platform independent 2. Object-orientated programming language 3. Interpreted and compiled language 4. Automatic memory management
  • 4. New Features in Java8: forEach() method in Iterable interface. default and static methods in interface. Functional interfaces and lambda expression. Java Stream API for Bulk Data Operation on Collection. Java Time API. Collection API improvements. Concurrency API improvements. Java IO improvements.
  • 5. forEach() method in Iterable interface: Whenever we need to traverse through a Collection, we need to create an Iterator whose whole purpose is to iterate over Java 8 has introduced forEach method in java.lang.Iterable interface so that while writing code we focus on logic only.
  • 6. default and static methods in interface: If you read forEach method details carefully, you will notice that it’s defined in Iterable interface but we know that interfaces can’t have method body.  From Java 8, interfaces are enhanced to have method with implementation. We can use default and static keyword to create interfaces with method implementation. Static methods, by definition, are not abstract . default void forEach(ClassName<? super T> action) { }
  • 7. Lambda Expression:  Implement Functional Programming Lambda expressions provide anonymous function types to Java. – Replace use of anonymous inner classes. – Provide more functional style of programming in Java. doSomething(new DoStuff() { public boolean isGood(int value) { return value == 42; } }); doSomething(answer -> answer == 42);
  • 8. Lambda Expressions in GUI Applications:  To process events in a graphical user interface (GUI) application, such as keyboard actions, mouse actions, and scroll actions, you typically create event handlers, which usually involves implementing a particular interface. Often, event handler interfaces are functional interfaces; they tend to have only one method. btn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { System.out.println("Hello World!"); } }); btn.setOnAction( event -> System.out.println("Hello World!") );
  • 9. Functional Interface: Single Abstract Method (SAM) type A functional interface is an interface that has one abstract method. – Represents a single function contract. – Doesn’t mean it only has one method . @FunctionalInterface annotation – Helps ensure the functional interface contract is honoured – Compiler error if not a SAM
  • 10. Extension Methods: Bringing Multiple Inheritance (of Functionality) to Java  Provide a mechanism to add new methods to existing interfaces – Without breaking backwards compatibility – Gives Java multiple inheritance of behavior, as well as types (but not state!) public interface Set extends Collection { public int size(); ... // The rest of the existing Set methods public T reduce(Reducer r) default Collections.setReducer; }
  • 11. Java Stream API: A new java.util.stream has been added in Java 8 to perform filter/map/reduce like operations with the collection.  This is one of the best feature because we work a lot with Collections and usually with Big Data, we need to filter out them based on some conditions. Collection interface has been extended with stream() and parallelStream() default methods to get the Stream for sequential and parallel execution. parallel processing will be very helpful while working with huge collections.
  • 12. Java Time API: It has always been hard to work with Date, Time and Time Zones in java. There was no standard approach or API in java for date and time in Java. One of the nice addition in Java 8 is the java.time package that will streamline the process of working with time in java. One of the useful class is DateTimeFormatter for converting date time objects to strings.
  • 13. Collection API improvements: Iterator default method forEachRemaining(ClassName object) to perform the given action for each remaining element until all elements have been processed or the action throws an exception. Collection default method removeIf(Predicate filter) to remove all of the elements of this collection that satisfy the given predicate. Collection spliterator() method returning Spliterator instance that can be used to traverse elements sequentially or parallel. Map replaceAll(), compute(), merge() methods.
  • 14. Performance Improvement for HashMap class with Key Collisions, how? in case of collision till Java 7 it used to store values in linked list and the search order for link list is O(n), but in java 8 it forms binary tree (O(log(n))) instead of linked list. This makes search faster, this would be useful in case of billions of records getting collide for same hash key.
  • 15. Concurrency API improvements: Files.list(Path dir) that returns a lazily populated Stream, the elements of which are the entries in the directory. Files.lines(Path path) that reads all lines from a file as a Stream. Files.find() that returns a Stream that is lazily populated with Path by searching for files in a file tree rooted at a given starting file. BufferedReader.lines() that return a Stream, the elements of which are lines read from this BufferedReader.
  • 16. Nashorn JavaScript Engine: Lightweight, high-performance JavaScript engine. – Integrated into JRE . Use existing javax.script API.  New command-line tool, jjs, to run JavaScript. It can run scripts as JavaFX applications Native javascript arrays are untyped. Nashorn enables you to use typed java arrays in javascript.
  • 17. Some Other Features: Comparator interface has been extended with a lot of default and static methods for natural ordering, reverse order etc. min(), max() and sum() methods in Integer, Long and Double wrapper classes. logicalAnd(), logicalOr() and logicalXor() methods in Boolean class. JDBC-ODBC Bridge has been removed.
  • 18. New Features in Java 8 end of presentation Thank you