SlideShare a Scribd company logo
What’s new in Java 8
Maxim Zakharenkov
3 April, 2014
Existing presentations
• Новое в JDK 8. Александр Ильин, Oracle
https://www.youtube.com/watch?v=lSnNWRABA1s
• JDK8: Stream style, Sergey Kuksenko, Oracle
http://www.slideshare.net/SergeyKuksenko/jdk8-stream-style
• More on slideshare
What this talk is about
• Streams
• Stream notes
• Some other new features in Java 8
– Optional<?>
– Annotations
– parallelSort
– Concurrency
– Some other stuff
Streams
Other presentation slides here
Whats New in Java 8
Whats New in Java 8
Whats New in Java 8
Whats New in Java 8
Whats New in Java 8
Whats New in Java 8
Whats New in Java 8
Whats New in Java 8
filter()
filter()
map()
filter()
map()
map()
filter()
map()
map()
distinct()
filter()
map()
map()
distinct()collect()
Stream notes: Short circuiting
Random random = new Random();
int[] result = IntStream
.generate(() ->random.nextInt())
.sorted()
.toArray();
Stream notes: parallel forEach
DEMO
Stream notes: parallel forEach
• forEach does not preserve order!
• Use forEachOrdered if order matters
Stream notes: not reusable
IntStream stream = Arrays.stream(new int[]{1, 2, 3, 4});
List<Object> list = stream.boxed().collect(Collectors.toList());
// this throws java.lang.IllegalStateException
double average = stream.average().getAsDouble();
Optional results 1
public String findById(int id) {
// ...
return …;
}
Optional results 2
public String findById(int id) {
// ...
return …;
}
String result = findById(10);
Optional results 3
public String findById(int id) {
// ...
return …;
}
String result = findById(10);
prefix = result.substring(0, 3);
Optional results 4
public String findById(int id) {
// ...
return …;
}
String result = findById(10);
if(result != null) {
prefix = result.substring(0, 3);
}
Optional results 5
public String ? findById(int id) {
// ...
return …;
}
String result = findById(10);
prefix = result.substring(0, 3);
Optional results 6
public Optional<String>
findById(int id) {
// ...
return …;
}
if(result.isPresent()) {
}
Annotations
public @NonNull String findById(int id) {
// ...
return …;
}
Checker framework
http://types.cs.washington.edu/checker-
framework/current/checkers-manual.html
Checker framework
• @Interned String intern() { ... } // return value
• int compareTo(@NonNull String other) { ... } // parameter
• String toString(@ReadOnly MyClass this) { ... } // receiver
• @NonNull List<@Interned String> messages; // generics: non-
null list of interned Strings
• @Interned String @NonNull [] messages; // arrays: non-null
array of interned Strings
• myDate = (@ReadOnly Date) readonlyObject; // cast
Arrays.parallelSort
• Works faster
• Everyting has own cost
– DualPivotQuickSort - sequental
– MergeSort - parallel
Parallel sort of 50M elements
(on my 4 core laptop)
• Single threaded DualPivotQuickSort: 47sec
• Parallel merge sort: 21sec
• Sequential stream: 95sec
• Parallel stream: 104sec
Parallelism, is it good or bad?
(example)
• 2 CPU
• Concurrent clients - 1000 queries per second
• Single sequential sort - 2ms
• Single parallel sort - 1ms + sync overhead ~1.2ms
• Less transactions per second with parallel sort
• Parallel algorithms do not always fit well
HashMap
0 key1
1
2
3
4
5
6
key2
key3
HashMap before Java 8
0 key1
1
2
3
4
5
6
key2
key3
key4 key4
HashMap in Java 8
0 key1
1
2
3
4
5
6
key2
key3
key4
key4
MissionControl
• Cool tool for JVM diagnostics
• Comes with JDK installation (jmc executable
• Now we have 3 similar tools in JDK
– jconsole
– jvisualvm
– jms
Future of frameworks
• Type-safe property references in Hibernate-
like query languages
• JUnit, Mockito-like frameworks with method
references
• Event handlers
• Better XML and JSON serializers
• - ….
QA

More Related Content

PPT
My first experience with lambda expressions in java
PPTX
RxJava Applied
PDF
Creating the PromQL Transpiler for Flux by Julius Volz, Co-Founder | Prometheus
PPTX
Introduction to TPL
PPTX
Scalable Applications with Scala
PPTX
DevNexus 2018: Learn Java 8, lambdas and functional programming
PPTX
Presto overview
PDF
Non Blocking I/O for Everyone with RxJava
My first experience with lambda expressions in java
RxJava Applied
Creating the PromQL Transpiler for Flux by Julius Volz, Co-Founder | Prometheus
Introduction to TPL
Scalable Applications with Scala
DevNexus 2018: Learn Java 8, lambdas and functional programming
Presto overview
Non Blocking I/O for Everyone with RxJava

What's hot (20)

PDF
Performance van Java 8 en verder - Jeroen Borgers
PDF
Quick Introduction to Kotlin Coroutine for Android Dev
PDF
Streaming data to s3 using akka streams
PDF
Functional Reactive Programming (CocoaHeads Bratislava)
PDF
java8-patterns
PDF
Clojure in real life 17.10.2014
PDF
DanNotes 2013: OpenNTF Domino API
PPTX
Non blocking programming and waiting
PDF
JDK8 Functional API
PDF
Wait for your fortune without Blocking!
PDF
cb streams - gavin pickin
PPTX
Utilizing the open ntf domino api
PPTX
Multi core programming 1
PDF
User defined-functions-cassandra-summit-eu-2014
PPTX
Parallel SQL for SolrCloud
PPTX
OpenNTF Domino API - Overview Introduction
PDF
#Pharo Days 2016 Data Formats and Protocols
PDF
Run time data areas
PDF
Streaming Data Flow with Apache Flink @ Paris Flink Meetup 2015
PDF
Converting a naive flow to akka streams
Performance van Java 8 en verder - Jeroen Borgers
Quick Introduction to Kotlin Coroutine for Android Dev
Streaming data to s3 using akka streams
Functional Reactive Programming (CocoaHeads Bratislava)
java8-patterns
Clojure in real life 17.10.2014
DanNotes 2013: OpenNTF Domino API
Non blocking programming and waiting
JDK8 Functional API
Wait for your fortune without Blocking!
cb streams - gavin pickin
Utilizing the open ntf domino api
Multi core programming 1
User defined-functions-cassandra-summit-eu-2014
Parallel SQL for SolrCloud
OpenNTF Domino API - Overview Introduction
#Pharo Days 2016 Data Formats and Protocols
Run time data areas
Streaming Data Flow with Apache Flink @ Paris Flink Meetup 2015
Converting a naive flow to akka streams
Ad

Viewers also liked (10)

PDF
Dart Workshop
PDF
Developing Useful APIs
PDF
Riding Redis @ask.fm
PPTX
Big Data Processing Using Hadoop Infrastructure
PDF
JOOQ and Flyway
PPTX
Архитектура Ленты на Одноклассниках
PDF
Automating Your Infrastructure
PDF
Crowdsourcing Expert Performance to Improve Training at Cyber Speed
PPT
Java Riga Day 2011 Opening
PPT
Creative Play with Technology
Dart Workshop
Developing Useful APIs
Riding Redis @ask.fm
Big Data Processing Using Hadoop Infrastructure
JOOQ and Flyway
Архитектура Ленты на Одноклассниках
Automating Your Infrastructure
Crowdsourcing Expert Performance to Improve Training at Cyber Speed
Java Riga Day 2011 Opening
Creative Play with Technology
Ad

Similar to Whats New in Java 8 (20)

PPT
Java user group 2015 02-09-java8
PPT
Java user group 2015 02-09-java8
PDF
What's new in Java 8
PDF
Java 8
PPTX
Java8: what's new and what's hot
PPTX
Java- Updates in java8-Mazenet solution
PDF
Java collections the force awakens
PDF
JDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go Wrong
PDF
JDK8: Stream style
PDF
NUS Hackers Club Mar 21 - Whats New in JavaSE 8?
PPTX
Java 8 Examples
PPTX
Java SE 8 - New Features
PPTX
New Features of JAVA SE8
PPTX
A brief tour of modern Java
PPTX
Modern Java Development
PPTX
Java Collection
PPTX
Improved Developer Productivity In JDK8
PPTX
JDK8 Streams
PDF
Java EE 8 - An instant snapshot
PPTX
Java days gbg online
Java user group 2015 02-09-java8
Java user group 2015 02-09-java8
What's new in Java 8
Java 8
Java8: what's new and what's hot
Java- Updates in java8-Mazenet solution
Java collections the force awakens
JDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go Wrong
JDK8: Stream style
NUS Hackers Club Mar 21 - Whats New in JavaSE 8?
Java 8 Examples
Java SE 8 - New Features
New Features of JAVA SE8
A brief tour of modern Java
Modern Java Development
Java Collection
Improved Developer Productivity In JDK8
JDK8 Streams
Java EE 8 - An instant snapshot
Java days gbg online

More from Dmitry Buzdin (20)

PDF
How Payment Cards Really Work?
PDF
Как построить свой фреймворк для автотестов?
PDF
How to grow your own Microservice?
PDF
How to Build Your Own Test Automation Framework?
PDF
Delivery Pipeline for Windows Machines
PDF
Rubylight JUG Contest Results Part II
PDF
Rubylight Pattern-Matching Solutions
PDF
Refactoring to Macros with Clojure
PPTX
Poor Man's Functional Programming
PDF
Rubylight programming contest
PPTX
Continuous Delivery
PPTX
Introduction to DevOps
PDF
Thread Dump Analysis
PDF
Pragmatic Java Test Automation
PDF
Mlocjs buzdin
PDF
Web polyglot programming
PPTX
Code Structural Analysis
PDF
Google Guava
PPT
Jug Intro 20
PDF
Jug intro 18
How Payment Cards Really Work?
Как построить свой фреймворк для автотестов?
How to grow your own Microservice?
How to Build Your Own Test Automation Framework?
Delivery Pipeline for Windows Machines
Rubylight JUG Contest Results Part II
Rubylight Pattern-Matching Solutions
Refactoring to Macros with Clojure
Poor Man's Functional Programming
Rubylight programming contest
Continuous Delivery
Introduction to DevOps
Thread Dump Analysis
Pragmatic Java Test Automation
Mlocjs buzdin
Web polyglot programming
Code Structural Analysis
Google Guava
Jug Intro 20
Jug intro 18

Recently uploaded (20)

PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
Complete React Javascript Course Syllabus.pdf
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PPTX
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
PPTX
ISO 45001 Occupational Health and Safety Management System
PPTX
Introduction to Artificial Intelligence
PPT
Introduction Database Management System for Course Database
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PPTX
history of c programming in notes for students .pptx
PPTX
ai tools demonstartion for schools and inter college
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
How Creative Agencies Leverage Project Management Software.pdf
PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
2025 Textile ERP Trends: SAP, Odoo & Oracle
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
VVF-Customer-Presentation2025-Ver1.9.pptx
Softaken Excel to vCard Converter Software.pdf
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Complete React Javascript Course Syllabus.pdf
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
ISO 45001 Occupational Health and Safety Management System
Introduction to Artificial Intelligence
Introduction Database Management System for Course Database
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
history of c programming in notes for students .pptx
ai tools demonstartion for schools and inter college
Design an Analysis of Algorithms II-SECS-1021-03
How Creative Agencies Leverage Project Management Software.pdf
ManageIQ - Sprint 268 Review - Slide Deck
How to Choose the Right IT Partner for Your Business in Malaysia

Whats New in Java 8