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

Last updated on 2018-12-13

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 lead software engineer at a healthcare startup.

  • Understanding the Java 7: the Core techniques and best practice (Simplified Chinese edition) covers Java SE 7 new features and deep dive of Java platform core features.
  • Build Mobile Apps with Ionic 2 and Firebase covers building mobile apps using Ionic 2 and Firebase.
  • Exploring Java 9 covers Java 9 module system and other new features.
  • A regular author on IBM developerWorks China and InfoQ China website with more than 50 published technical articles covering various technical topics.

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

The Leanpub 45-day 100% Happiness Guarantee

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

See full terms...

Write and Publish on Leanpub

Authors, publishers and universities use Leanpub to publish amazing in-progress and completed books and courses, just like this one. You can use Leanpub to write, publish and sell your book or course as well! 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. It really is that easy.

Learn more about writing on Leanpub