Table of Contents for
Modern Java Recipes
Close
Version ebook
/
Retour
Modern Java Recipes
by Ken Kousen
Published by O'Reilly Media, Inc., 2017
nav
Cover
Modern Java Recipes
Modern Java Recipes
Dedication
Foreword
Preface
The Basics
The java.util.function Package
Streams
Comparators and Collectors
Issues with Streams, Lambdas, and Method References
The Optional Type
File I/O
The java.time Package
Parallelism and Concurrency
Java 9 Additions
Generics and Java 8
Index
About the Author
Colophon
Foreword
Preface
Modern Java
Who Should Read This Book
How This Book Is Organized
Conventions Used in This Book
Using Code Examples
O’Reilly Safari
How to Contact Us
Acknowledgments
The Basics
1.1. Lambda Expressions
1.2. Method References
1.3. Constructor References
1.4. Functional Interfaces
1.5. Default Methods in Interfaces
1.6. Static Methods in Interfaces
The java.util.function Package
2.1. Consumers
2.2. Suppliers
2.3. Predicates
2.4. Functions
Streams
3.1. Creating Streams
3.2. Boxed Streams
3.3. Reduction Operations Using Reduce
3.4. Check Sorting Using Reduce
3.5. Debugging Streams with peek
3.6. Converting Strings to Streams and Back
3.7. Counting Elements
3.8. Summary Statistics
3.9. Finding the First Element in a Stream
3.10. Using anyMatch, allMatch, and noneMatch
3.11. Stream flatMap Versus map
3.12. Concatenating Streams
3.13. Lazy Streams
Comparators and Collectors
4.1. Sorting Using a Comparator
4.2. Converting a Stream into a Collection
4.3. Adding a Linear Collection to a Map
4.4. Sorting Maps
4.5. Partitioning and Grouping
4.6. Downstream Collectors
4.7. Finding Max and Min Values
4.8. Creating Immutable Collections
4.9. Implementing the Collector Interface
Issues with Streams, Lambdas, and Method References
5.1. The java.util.Objects Class
5.2. Lambdas and Effectively Final
5.3. Streams of Random Numbers
5.4. Default Methods in Map
5.5. Default Method Conflict
5.6. Iterating Over Collections and Maps
5.7. Logging with a Supplier
5.8. Closure Composition
5.9. Using an Extracted Method for Exception Handling
5.10. Checked Exceptions and Lambdas
5.11. Using a Generic Exception Wrapper
The Optional Type
6.1. Creating an Optional
6.2. Retrieving Values from an Optional
6.3. Optional in Getters and Setters
6.4. Optional flatMap Versus map
6.5. Mapping Optionals
File I/O
7.1. Process Files
7.2. Retrieving Files as a Stream
7.3. Walking the Filesystem
7.4. Searching the Filesystem
The java.time Package
8.1. Using the Basic Date-Time Classes
8.2. Creating Dates and Times from Existing Instances
8.3. Adjusters and Queries
8.4. Convert from java.util.Date to java.time.LocalDate
8.5. Parsing and Formatting
8.6. Finding Time Zones with Unusual Offsets
8.7. Finding Region Names from Offsets
8.8. Time Between Events
Parallelism and Concurrency
9.1. Converting from Sequential to Parallel Streams
9.2. When Parallel Helps
9.3. Changing the Pool Size
9.4. The Future Interface
9.5. Completing a CompletableFuture
9.6. Coordinating CompletableFutures, Part 1
9.7. Coordinating CompletableFutures, Part 2
Java 9 Additions
10.1. Modules in Jigsaw
10.2. Private Methods in Interfaces
10.3. Creating Immutable Collections
10.4. Stream: ofNullable, iterate, takeWhile, and dropWhile
10.5. Downstream Collectors: filtering and flatMapping
10.6. Optional: stream, or, ifPresentOrElse
10.7. Date Ranges
Generics and Java 8
Background
What Everybody Knows
What Some Developers Don’t Realize
Wildcards and PECS
Examples from the Java 8 API
Summary
Index