Your Guide to Java Streams [Tutorials and Articles]
Join the DZone community and get the full member experience.
Join For FreeIn this edition of "Best of DZone," we've compiled our best tutorials and articles on one of the most popular APIs in Java, Streams. Whether you're a beginner just looking to bring in some elements of functional programming into a Java application, or a Streams vet, we've got your back!
Before we begin, we'd like need to thank those who were a part of this article. DZone has and continues to be a community powered by contributors like you who are eager and passionate to share what they know with the rest of the world.
Let's get started!
Overview
A Guide to Streams: In-Depth Tutorial With Examples by Eugen Paraschiv — Java 8 and streams: A match made in heaven, but it can be a little overwhelming. In this post, we take an in-depth look at this combination with some examples.
Dipping Into Java 8 Streams by Dan Newton — With a working knowledge of lambda expressions and method references, you can see how streams enable you to work with Collections while efficiently adding logic.
Java Streams Overview, Part 1 and Part 2 by Zoltan Raffai — Get started working with Streams and learn everything you need to get started with basic classes, reading and writing operations, and working with errors.
A Java 8 Streams Cookbook by Martin Farrell — If you're looking for a quick breakdown of Streams, look no further. This cookbook covers Streams' chief advantages, its operations, and a comprehensive example.
Processing Collections
Process Collections Easily With Stream in Java 8 by Leona Zhang — Learn how you can process collections easily with Stream in Java 8.
How to Compare List Objects in Java 7 vs. Java 8 by Arpan Das — In this blast from the not-too-distant past, we compare how Java 8's Stream API changed how you can compare List objects.
Mastering Java 8 Streams Part 1 and Part 2 by Marco Behler — Want to get your feet wet with Java streams? This introductory video will get you creating streams and performing simple tasks on them.
Convert a List to a Comma-Separated String in Java 8 by Mario Pio Gioiosa — This quick tutorial shows you how to use streams in Java to convert the contents of a list to a comma-separated string in Java 8.
Working With Files
Split a File as a Stream by Peter Verhas — Curious about when you would actually use the
splitAsStream
method? Here's a use case of splitting a file into chunks that can be processed as streams.Java 8 Stream and Lambda Expressions – Parsing File Example by Eyal Golan — See a common use case for Streams and Lambda Expressions in this article.
Parallel Streams
Think Twice Before Using Java 8 Parallel Streams by Lukas Krecan — Parallelization was the main driving force behind lambdas, stream API, and others. Let's take a look at an example of stream API.
Should I Parallelize Java 8 Streams? by Santhosh Krishnan — What do we need to consider before parallelizing Java streams?
Streams and Collectors
Using Java Streams and Collectors by Jay Sridhar — This short guide covers how to use Java 8 Streams and Collectors to slice and dice lists, including computing sums, averages, and partitioning.
How to Use Java Stream Collectors by Yogen Rai — Want to learn more about using Java Stream collectors? Check out this post on collectors and how to use them.
How to Transform Elements In a Stream Using a Collector by Hubert Klein Ikkink — Learn more about how to transform elements in a Stream using Java Collectors.
The Ultimate Guide to the Java Stream API groupingBy() Collector by Grzegorz Piwowarek — Still a bit puzzled by what the
groupingBy()
collector can do in the Java Stream API? Check out this guide on using thegroupingBy()
collector to its fullest potential.
Stream Bugs
Java Stream API Was Broken Before JDK 10 by Grzegorz Piwowarek — Stream API bugs can affect anyone still residing on JDK 8 and JDK 9. Click here to learn more.
Lambda Streams
Java Lambda Streams and Groovy Closures Comparisons by Alex Staveley — Want to learn more about the difference between in lambda streams in both Java and Groovy? Check out this post to learn more about the differences between them.
Advanced Topics
Are Java 8 Streams Truly Lazy? Not Completely! by Lukas Eder — Is it always the case that streams in Java 8 are evaluated lazily? Check out this article and find a possibly surprising result.
Overview of Java Stream API Extensions by Piotr Mińkowski — Check out the top Java Stream API extensions offered by popular Java libraries.
Java Stream: Is a Count Always a Count? Part 1 and Part 2 by Per-Åke Minborg — Learn more about counts in Java streams.
How to Reuse Java Streams by Miguel Gamboa — Need to use your streams over and over again? Let's cover three different approaches, their benefits, and their pitfalls when recycling Java streams.
Become a Master of Java Streams, Part 1: Creating Streams, Part 2: Intermediate Operations, Part 3: Terminal Operations, and Part 4: Database Streams, Part 5: Turn Joined Database Tables Into a Stream, and Part 6: Creating a New Database Application Using Streams by Per-Åke Minborg and Julia Gustafsson — Want to become a Java Streams Master?
Exception Handling in Java Streams by Brian Vermeer — When you want to use a method that throws a
checkedException
, you have to do something extra if you want to call it in a lambda.Peeking Inside Java Streams With Stream.peek by Dustin Marx — How to use the Stream.peek(Consumer) method in Java to help visualize stream operations.
Be a Part of the Conversation!
Think we missed something? Want to contribute? Let us know in the comments below... or, join the conversation by becoming a member of our community of thousands of developers eager to share their knowledge and passion for programming with others.
Further Reading
Opinions expressed by DZone contributors are their own.
Comments