Home
Explore
Submit Search
Upload
Login
Signup
Advertisement
Check these out next
Apouc 2014-java-8-create-the-future
OUGTH Oracle User Group in Thailand
Functional Programming With Lambdas and Streams in JDK8
IndicThreads
Introduction to new features in java 8
New York City College of Technology Computer Systems Technology Colloquium
Java SE 8 - New Features
Naveen Hegde
Lambdas & Streams
C4Media
Streams in Java 8
Tobias Coetzee
Java 8
Sudipta K Paik
Project Lambda: Functional Programming Constructs in Java - Simon Ritter (Ora...
jaxLondonConference
1
of
17
Top clipped slide
Lambdas And Streams Hands On Lab, JavaOne 2014
Oct. 2, 2014
•
0 likes
5 likes
×
Be the first to like this
Show More
•
1,509 views
views
×
Total views
0
On Slideshare
0
From embeds
0
Number of embeds
0
Download Now
Download to read offline
Report
Software
Simon Ritter
Follow
Java Evangelist at Oracle
Advertisement
Advertisement
Advertisement
Recommended
Lambdas And Streams Hands On Lab
Simon Ritter
806 views
•
28 slides
Lambdas and-streams-s ritter-v3
Simon Ritter
1.2K views
•
38 slides
Lambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon Ritter
JAXLondon2014
1.3K views
•
42 slides
JDK8 Lambdas and Streams: Changing The Way You Think When Developing Java
Simon Ritter
2.9K views
•
61 slides
Lambdas : Beyond The Basics
Simon Ritter
3K views
•
44 slides
Lambdas Hands On Lab
Simon Ritter
1.7K views
•
28 slides
More Related Content
Slideshows for you
(20)
Apouc 2014-java-8-create-the-future
OUGTH Oracle User Group in Thailand
•
1.5K views
Functional Programming With Lambdas and Streams in JDK8
IndicThreads
•
1.7K views
Introduction to new features in java 8
New York City College of Technology Computer Systems Technology Colloquium
•
936 views
Java SE 8 - New Features
Naveen Hegde
•
1.6K views
Lambdas & Streams
C4Media
•
944 views
Streams in Java 8
Tobias Coetzee
•
1K views
Java 8
Sudipta K Paik
•
104 views
Project Lambda: Functional Programming Constructs in Java - Simon Ritter (Ora...
jaxLondonConference
•
2.2K views
Object Oriented Programming Using C++ (Slides 5/5)
Adil Aslam
•
2.5K views
File Handling in C++
Adil Aslam
•
17.8K views
Object Oriented Programming Using C++ (Slides 2/5)
Adil Aslam
•
4.6K views
How Green are Java Best Coding Practices? - GreenDays @ Rennes - 2014-07-01
Jérôme Rocheteau
•
1.1K views
Java 8 streams
Manav Prasad
•
1K views
Java 8 lambda
Manav Prasad
•
2.2K views
Introduction to C++ Lecture No. 27
Adil Aslam
•
4.6K views
Chap2java5th
Asfand Hassan
•
871 views
Introduction To Java Programming Lecture No. 7
Adil Aslam
•
2.2K views
3. Data types and Variables
Nilesh Dalvi
•
1.9K views
Introduction To C++ Lecture No. 7
Adil Aslam
•
2.3K views
Chap1java5th
Asfand Hassan
•
1.4K views
Similar to Lambdas And Streams Hands On Lab, JavaOne 2014
(20)
JDK8 Streams
Bansilal Haudakari
•
260 views
What's New in Java 8
javafxpert
•
42.2K views
Functional programming with_jdk8-s_ritter
Simon Ritter
•
2.2K views
New features in jdk8 iti
Ahmed mar3y
•
78 views
Improved Developer Productivity In JDK8
Simon Ritter
•
3.7K views
MapReduce Design Patterns
Donald Miner
•
19.9K views
Lambdas And Streams in JDK8
Simon Ritter
•
866 views
New Features in JDK 8
Martin Toshev
•
19.2K views
Java 8 Intro - Core Features
GlobalLogic Ukraine
•
1.4K views
What's new in java 8
Dian Aditya
•
124 views
Java 8 New features
Son Nguyen
•
1.2K views
Java8
Felipe Mamud
•
4K views
Java 8: more readable and flexible code
WeAreEsynergy
•
963 views
Integrate SparkR with existing R packages to accelerate data science workflows
Artem Ervits
•
357 views
Big Data Analytics-Open Source Toolkits
DataWorks Summit
•
3.5K views
documents.pub_new-features-in-java-8-it-jpoialjavanaitedwien15java8pdf-java-8...
Akaks
•
4 views
A Brief Conceptual Introduction to Functional Java 8 and its API
Jörn Guy Süß JGS
•
179 views
Rdf Processing On The Java Platform
guestc1b16406
•
1.1K views
Colloquium Report
Mohammad Faizan
•
748 views
Novidades do Java SE 8
Bruno Borges
•
3.3K views
Advertisement
More from Simon Ritter
(20)
Cloud Native Compiler
Simon Ritter
•
46 views
Java On CRaC
Simon Ritter
•
368 views
The Art of Java Type Patterns
Simon Ritter
•
191 views
Modern Java Workshop
Simon Ritter
•
250 views
Java performance monitoring
Simon Ritter
•
601 views
Modern Java Workshop
Simon Ritter
•
729 views
Getting the Most From Modern Java
Simon Ritter
•
417 views
Building a Better JVM
Simon Ritter
•
108 views
JDK 14 Lots of New Features
Simon Ritter
•
510 views
Java after 8
Simon Ritter
•
220 views
How to Choose a JDK
Simon Ritter
•
231 views
Java Programming
Simon Ritter
•
1.2K views
The Latest in Enterprise JavaBeans Technology
Simon Ritter
•
1.2K views
Developing Enterprise Applications Using Java Technology
Simon Ritter
•
962 views
Is Java Still Free?
Simon Ritter
•
261 views
Moving Towards JDK 12
Simon Ritter
•
844 views
JDK 9, 10, 11 and Beyond
Simon Ritter
•
1.9K views
Java Is Still Free
Simon Ritter
•
1.2K views
JDK 9, 10, 11 and Beyond
Simon Ritter
•
837 views
JDK 9 and JDK 10 Deep Dive
Simon Ritter
•
1.5K views
Recently uploaded
(20)
Customized ERP software development
babuprasad38
•
0 views
lecture 6 DES part1.pdf
ssuser6c54131
•
0 views
Data Communication-1.ppt
ssusere16bd9
•
0 views
在哪里可以办英国大学文凭《白金汉大学毕业证成绩单仿制》
efagvah
•
3 views
React JS in Blockchain Development.pptx
AriHemingway
•
0 views
SugarCRM.ppt
RajJar12
•
1 view
Prosper part 1.pdf
HazemKolieb
•
4 views
Prolog PPT_merged.pdf
20CE112YASHPATEL
•
0 views
ASDialer | Differences between Predictive and Progressive Dialers In 2023
Aresync
•
0 views
javascript_tutorial.pdf
kaouthar20
•
4 views
ch11lect1.ppt
NupurMishra34
•
2 views
PyCon Ireland 2022 - PyArrow full stack.pdf
Alessandro Molina
•
0 views
Characteristics of the Zero Trust Security Model
CloudStakes Technology
•
0 views
natural-language-processing.ppt
MuhammadAnas729373
•
1 view
意大利罗马二大毕业证文凭成绩单制作指南
nahej99297
•
3 views
QA or the Highway - Extra-functional testing, improve how you observe the sys...
Federico Toledo
•
0 views
software companies in oamn muscat.pdf
WideSolutions
•
0 views
PPT Web Clustering Engine.pptx
DhammanandLonare
•
2 views
software companies in oamn muscat.pptx
WideSolutions
•
0 views
在哪里可以办澳洲大学文凭《南澳大学毕业证成绩单仿制》
efagvah
•
2 views
Advertisement
Lambdas And Streams Hands On Lab, JavaOne 2014
Lambdas & Streams
Laboratory Stuart Marks Simon Ritter Angela Caicedo Oracle Corp. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Lambdas and Functions
Copyright © 2012, Oracle and/or its affiliates. 3 All rights reserved. Library Review
Lambda Expressions
Lambda expression is an anonymous function Think of it like a method – But not associated with a class Can be used wherever you would use an anonymous inner class – Single abstract method type Syntax – ([optional-parameters]) -> body Types can be inferred (parameters and return type) Copyright © 2012, Oracle and/or its affiliates. 4 All rights reserved.
Lambda Examples SomeList<Student>
students = ... double highestScore = students.stream(). filter(Student s -> s.getGradYear() == 2011). map(Student s -> s.getScore()). max(); Copyright © 2012, Oracle and/or its affiliates. 5 All rights reserved.
Method References •
Method references let us reuse a method as a lambda expression FileFilter x = new FileFilter() { public boolean accept(File f) { FileFilter x = (File f) -> f.canRead(); FileFilter x = File::canRead; Copyright © 2012, Oracle and/or its affiliates. 6 All rights reserved. return f.canRead(); } };
The Stream Class
java.util.stream Stream<T> – A sequence of elements supporting sequential and parallel operations A Stream is opened by calling: – Collection.stream() – Collection.parallelStream() Many Stream methods return Stream objects – Very simple (and logical) method chaining Copyright © 2012, Oracle and/or its affiliates. 7 All rights reserved.
Stream Basics
Using a Stream means having three things A source – Something that creates a Stream of objects Zero or more intermediate objects – Take a Stream as input, produce a Stream as output – Potentially modify the contents of the Stream (but don’t have to) A terminal operation – Takes a Stream as input – Consumes the Stream, or generates some other type of output Copyright © 2012, Oracle and/or its affiliates. 8 All rights reserved.
Stream Usage
Multiple operations available – collect, filter, count, skip, limit, sorted – map (and map to types, e.g. mapToInt) – flatMap maps each element in a Stream to possibly multiple elements e.g. flatMap(line -> Stream.of(line.split(REGEXP)); List<String> names = Arrays.asList(“Bob”, “Alice”, “Charlie”); System.out.println(names. stream(). filter(e -> e.getLength() > 4). findFirst(). get()); Copyright © 2012, Oracle and/or its affiliates. 9 All rights reserved.
java.util.function Package
Predicate<T> – Determine if the input of type T matches some criteria Consumer<T> – Accept a single input argumentof type T, and return no result Function<T, R> – Apply a function to the input type T, generating a result of type R Plus several more Copyright © 2012, Oracle and/or its affiliates. 10 All rights reserved.
The iterable Interface
Used by most collections One method – forEach() – The parameter is a Consumer wordList.forEach(s -> System.out.println(s)); wordList.forEach(System.out::println); Copyright © 2012, Oracle and/or its affiliates. 11 All rights reserved.
Files and Lines
of Text BufferedReader has new method – Stream<String> lines() HINT: Test framework creates a BufferedReader for you Copyright © 2012, Oracle and/or its affiliates. 12 All rights reserved.
Maps and FlatMaps
Map Values in a Stream Map FlatMap Input Stream Input Stream Copyright © 2012, Oracle and/or its affiliates. 13 All rights reserved. 1 to 1 mapping 1 to many mapping Output Stream Output Stream
Useful Stream Methods
collect (terminal) filter (intermediate) count (terminal) skip, limit (intermediate) max (terminal) getAsInt (terminal) Copyright © 2012, Oracle and/or its affiliates. 14 All rights reserved.
Getting Started
Open the LambdasHOL project in NetBeans The exercises are configured as tests Edit the tests – Remove the @Ignore annotation Run the tests (Ctrl F6, or from the menu) Make the tests pass Simple! Copyright © 2012, Oracle and/or its affiliates. 15 All rights reserved.
Copyright © 2012,
Oracle and/or its affiliates. 16 All rights reserved. Let’s Go!
Copyright © 2012,
Oracle and/or its affiliates. 17 All rights reserved.
Advertisement