Java guides
Every published Java guide, newest first, with practical examples you can copy into your own project.
3,965 guides across 14 topics
Topics
Popular Java guides
Most readLatest Java guides
Page 33 of 109Java Collectors Counting: How to Count Stream Items
Learn how to use Collectors.counting() in Java streams to count elements, group counts by key, and understand when to use Stream.count() instead.
Java Collectors.partitioningBy With Examples
Learn how Java Collectors.partitioningBy splits a stream into two groups by a predicate, with downstream collectors, null handling, and practical tradeoffs.
Java Collectors groupingBy: Usage and Examples
java collectors groupingby: Learn how to use Java Collectors.groupingBy to group stream elements into maps, handle null keys, apply downstream collectors, and choose b...
Java Collectors Joining: Concatenating Stream Elements
java collectors joining: Learn how Collectors.joining() concatenates stream elements into a single String, covering all three overloads, null handling, performance beh...
Java Collectors.toMap: Usage and Edge Cases
Learn how to use Java's Collectors.toMap() to convert streams into maps, handle duplicate keys with merge functions, and avoid common pitfalls.
Java Collectors.toSet() Explained
Learn how to use Java's Collectors.toSet() to collect stream elements into a Set, including duplicate handling, ordering, performance, and alternatives.
Java Collectors toList: Usage and Behavior
Learn how Java's Collectors.toList() works, what it returns, and how it compares with Stream.toList(), toCollection(), and toUnmodifiableList().
Using Java Stream collect() to Build Collections
Learn how Java's Stream.collect() works and which Collectors to use for lists, maps, grouping, partitioning, joining, and custom collectors, plus common pitfalls to avoid.
Java Stream toList: Usage and Key Differences
Learn how Java's Stream.toList() works, how it differs from collect(Collectors.toList()), and when to use each approach.
Understanding Java Stream forEachOrdered
Explains java stream foreachordered: encounter order guarantees, the difference from forEach in parallel streams, and when the ordering cost is worth paying.