Leanpub Header

Skip to main content

A Practical Guide for Java 8 Lambdas and Streams

Mastering Java 8 Lambdas and Streams

A practical guide to Java 8 lambda expressions and streams, worth reading for Java developers.

The author is letting you choose the price you pay for this book!

Pick Your Price...

Buying multiple copies for your team? See below for a discount!

PDF
EPUB
WEB
About

About

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.

Share this book

Categories

Price

Pick Your Price...

Minimum price

$10.00

$15.00

You pay

$15.00

Author earns

$12.00
$

All prices are in US $. You can pay in US $ or in your local currency when you check out.

EU customers: prices exclude VAT, which is added during checkout.

...Or Buy With Credits!

Number of credits (Minimum 1)

1
The author will earn $12.00 from your purchase!
You can get credits monthly with a Reader Membership

Team Discounts

Team Discounts

Get a team discount on this book!

  • Up to 3 members

    Minimum price
    $25.00
    Suggested price
    $25.00
  • Up to 5 members

    Minimum price
    $40.00
    Suggested price
    $40.00
  • Up to 10 members

    Minimum price
    $70.00
    Suggested price
    $70.00
  • Up to 15 members

    Minimum price
    $100.00
    Suggested price
    $100.00
  • Up to 25 members

    Minimum price
    $150.00
    Suggested price
    $150.00

Author

About the Author

Fu Cheng

Full-stack software developer and content creator.

Contents

Table of Contents

1.Introduction

2.Lambda expressions

  1. 2.1Start a thread - A simple example
  2. 2.2Functional interfaces
  3. Functional interfaces and single responsibility principle
  4. 2.3Target typing
  5. Standalone expressions and Poly expressions
  6. 2.4Lambda expressions
  7. 2.5Lexical scoping
  8. 2.6Effectively final local variables
  9. 2.7Method references
  10. 2.7.1Types of method references
  11. 2.8Default interface methods
  12. 2.8.1Static interface methods

3.Functional interfaces

  1. 3.1Functions
  2. 3.1.1Function
  3. 3.1.2BiFunction
  4. 3.1.3Function and BiFunction with predefined types
  5. 3.2Consumers
  6. 3.2.1Consumer
  7. 3.2.2BiConsumer
  8. 3.2.3Consumer with predefined types
  9. 3.2.4Example of using Consumer
  10. 3.3Suppliers
  11. 3.3.1Supplier
  12. 3.3.2Supplier with predefined types
  13. 3.4Predicates
  14. 3.4.1Predicate
  15. 3.4.2BiPredicate
  16. 3.4.3Predicate and BiPredicate with predefined types
  17. 3.5Operators
  18. 3.5.1UnaryOperator
  19. 3.5.2BinaryOperator
  20. 3.5.3Operators with predefined types

4.Streams

  1. 4.1User-specified behavior
  2. 4.2Basic stream concepts
  3. 4.2.1Sequential or parallel
  4. 4.2.2Encounter order
  5. 4.3Stream operation characteristics
  6. 4.3.1Stateful or stateless
  7. 4.4Stream
  8. 4.5Spliterator
  9. 4.5.1Spliterator characteristics
  10. 4.5.2Spliterators for primitive types
  11. 4.5.3Spliterators to create Spliterators
  12. 4.5.4Late-binding and fail-fast
  13. 4.6BaseStream
  14. 4.7StreamSource
  15. 4.8Stream static methods
  16. 4.9Stream sources
  17. 4.9.1Arrays
  18. 4.9.2Collections
  19. 4.9.3Stream builder
  20. 4.9.4I/O channels
  21. 4.9.4.1lines
  22. 4.9.4.2list
  23. 4.9.4.3walk
  24. 4.9.4.4find
  25. 4.10Examples for stream processing
  26. 4.11Stream intermediate operations
  27. 4.11.1map
  28. 4.11.2flatMap
  29. 4.11.3filter
  30. 4.11.4distinct
  31. 4.11.5limit
  32. 4.11.6skip
  33. 4.11.7sorted
  34. 4.11.8peek
  35. 4.11.9Operations chaining
  36. 4.12Stream terminal operations
  37. 4.12.1forEach and forEachOrdered
  38. 4.12.2reduce
  39. 4.12.3max and min
  40. 4.12.4match
  41. 4.12.5find
  42. 4.12.6toArray
  43. 4.12.7collect
  44. 4.12.8Collectors
  45. 4.12.8.1Collect into collections
  46. 4.12.8.2groupingBy
  47. 4.12.8.3joining
  48. 4.12.8.4mapping
  49. 4.12.8.5partitioningBy
  50. 4.12.8.6counting
  51. 4.12.8.7averaging
  52. 4.12.8.8summing
  53. 4.12.8.9maxBy and minBy
  54. 4.12.8.10summarizing
  55. 4.12.8.11collectingAndThen
  56. 4.12.8.12reducing
  57. 4.12.9Parallel stream
  58. 4.12.9.1Parallel reduction
  59. 4.13How-tos
  60. 4.13.1How to convert a Collection to a Map?
  61. 4.13.2How to filter map entries by keys?
  62. 4.13.3How to filter map entries by values?
  63. 4.13.4How to group elements by multiple conditions?
  64. 4.13.5How to combine multiple collections into a stream?
  65. 4.13.6How to convert a stream to another stream with different type?
  66. 4.13.7How to find an element in the stream?
  67. 4.13.8How to sort map entries?
  68. 4.13.9How to do multiple operations on a stream?
  69. 4.13.10How to count elements after grouping?
  70. 4.13.11Exceptions Handling in Streams

5.Optional

  1. 5.1What’s Optional
  2. 5.2Usage of Optional
  3. 5.2.1Simple usage
  4. 5.2.2Chained usage
  5. 5.2.3Functional usage
  6. 5.3How-tos
  7. 5.3.1How to interact with legacy library code before Optional?
  8. 5.3.2How to get value from chained Optional reference path?
  9. 5.3.3How to get first value of a list of Optionals?
  10. 5.3.4How to chain method invocations with return value of Optional objects in sequence?
  11. 5.3.5How to convert an Optional object to a stream?
  12. 5.3.6How to use Optional to check for null and assign default values?
  13. 5.4Updates after Java 8

Get the free sample chapters

Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

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 earned over $14 million writing, 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