A Practical Guide for Java 8 Lambdas and Streams
$10.00
Minimum price
$10.00
Suggested price

A Practical Guide for Java 8 Lambdas and Streams

Mastering Java 8 Lambdas and Streams

About the Book

This book is not the first book about Java 8 lambda expressions and streams, and it's definitely not the last book about lambda expressions and streams. Java 8 is a Java platform upgrade which the community looking forward to for a long time. Lambda expressions and streams quickly gain popularity in Java developers. There are already a lot of books and online tutorials about lambda expressions and streams. This book is trying to explain lambda expressions and streams from a different perspective.

  •  For lambda expressions, this book explains in details based on JSR 335.
  •  For streams, this book covers fundamental concepts of Java core library.
  • This book provides how-to examples for lambda expressions and streams.
  • This book also covers the important utility class Optional.

Lambda expressions and streams are easy to understand and use. This book tries to provide some insights about how to use them efficiently.

About the Author

Fu Cheng
Fu Cheng

Full-stack software developer and content creator.

Bundles that include this book

$67.00
Bought separately
$35.00
Minimum price
$40.00
Suggested price

Table of Contents

  • 1. Introduction
  • 2. Lambda expressions
    • 2.1 Start a thread - A simple example
    • 2.2 Functional interfaces
    • 2.3 Target typing
    • 2.4 Lambda expressions
    • 2.5 Lexical scoping
    • 2.6 Effectively final local variables
    • 2.7 Method references
      • 2.7.1 Types of method references
    • 2.8 Default interface methods
      • 2.8.1 Static interface methods
  • 3. Functional interfaces
    • 3.1 Functions
      • 3.1.1 Function
      • 3.1.2 BiFunction
      • 3.1.3 Function and BiFunction with predefined types
    • 3.2 Consumers
      • 3.2.1 Consumer
      • 3.2.2 BiConsumer
      • 3.2.3 Consumer with predefined types
      • 3.2.4 Example of using Consumer
    • 3.3 Suppliers
      • 3.3.1 Supplier
      • 3.3.2 Supplier with predefined types
    • 3.4 Predicates
      • 3.4.1 Predicate
      • 3.4.2 BiPredicate
      • 3.4.3 Predicate and BiPredicate with predefined types
    • 3.5 Operators
      • 3.5.1 UnaryOperator
      • 3.5.2 BinaryOperator
      • 3.5.3 Operators with predefined types
  • 4. Streams
    • 4.1 User-specified behavior
    • 4.2 Basic stream concepts
      • 4.2.1 Sequential or parallel
      • 4.2.2 Encounter order
    • 4.3 Stream operation characteristics
      • 4.3.1 Stateful or stateless
    • 4.4 Stream
    • 4.5 Spliterator
      • 4.5.1 Spliterator characteristics
      • 4.5.2 Spliterators for primitive types
      • 4.5.3 Spliterators to create Spliterators
      • 4.5.4 Late-binding and fail-fast
    • 4.6 BaseStream
    • 4.7 StreamSource
    • 4.8 Stream static methods
    • 4.9 Stream sources
      • 4.9.1 Arrays
      • 4.9.2 Collections
      • 4.9.3 Stream builder
      • 4.9.4 I/O channels
        • 4.9.4.1 lines
        • 4.9.4.2 list
        • 4.9.4.3 walk
        • 4.9.4.4 find
    • 4.10 Examples for stream processing
    • 4.11 Stream intermediate operations
      • 4.11.1 map
      • 4.11.2 flatMap
      • 4.11.3 filter
      • 4.11.4 distinct
      • 4.11.5 limit
      • 4.11.6 skip
      • 4.11.7 sorted
      • 4.11.8 peek
      • 4.11.9 Operations chaining
    • 4.12 Stream terminal operations
      • 4.12.1 forEach and forEachOrdered
      • 4.12.2 reduce
      • 4.12.3 max and min
      • 4.12.4 match
      • 4.12.5 find
      • 4.12.6 toArray
      • 4.12.7 collect
      • 4.12.8 Collectors
        • 4.12.8.1 Collect into collections
        • 4.12.8.2 groupingBy
        • 4.12.8.3 joining
        • 4.12.8.4 mapping
        • 4.12.8.5 partitioningBy
        • 4.12.8.6 counting
        • 4.12.8.7 averaging
        • 4.12.8.8 summing
        • 4.12.8.9 maxBy and minBy
        • 4.12.8.10 summarizing
        • 4.12.8.11 collectingAndThen
        • 4.12.8.12 reducing
      • 4.12.9 Parallel stream
        • 4.12.9.1 Parallel reduction
    • 4.13 How-tos
      • 4.13.1 How to convert a Collection to a Map?
      • 4.13.2 How to filter map entries by keys?
      • 4.13.3 How to filter map entries by values?
      • 4.13.4 How to group elements by multiple conditions?
      • 4.13.5 How to combine multiple collections into a stream?
      • 4.13.6 How to convert a stream to another stream with different type?
      • 4.13.7 How to find an element in the stream?
      • 4.13.8 How to sort map entries?
      • 4.13.9 How to do multiple operations on a stream?
      • 4.13.10 How to count elements after grouping?
      • 4.13.11 Exceptions Handling in Streams
  • 5. Optional
    • 5.1 What’s Optional
    • 5.2 Usage of Optional
      • 5.2.1 Simple usage
      • 5.2.2 Chained usage
      • 5.2.3 Functional usage
    • 5.3 How-tos
      • 5.3.1 How to interact with legacy library code before Optional?
      • 5.3.2 How to get value from chained Optional reference path?
      • 5.3.3 How to get first value of a list of Optionals?
      • 5.3.4 How to chain method invocations with return value of Optional objects in sequence?
      • 5.3.5 How to convert an Optional object to a stream?
      • 5.3.6 How to use Optional to check for null and assign default values?
    • 5.4 Updates after Java 8

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earnedover $14 millionwriting, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub