CodeGym
CodeGym University
Java FullStack
Learning
Courses
Tasks
Surveys & Quizzes
Games
Help
Schedule
Community
Users
Forum
Chat
Articles
Success stories
Activity
Reviews
Subscriptions
Light theme

Lessons

  • Reviews
  • About us
Start
Start learning
Start learning now
  • My Progress
  • Courses
  • University
  • Quest Map
  • Lessons
  • Methods groupingBy and partitioningBy (Collectors)

    JAVA 25 SELF
    Level 31, Lesson 2
    In this lecture, you will learn to group data in streams using the collectors Collectors.groupingBy and Collectors.partitioningBy: simple and nested grouping, splitting by a boolean predicate, choosing between them, processing the result, and tips and tricks. With practical examples using strings, numbers, and objects, you will see how to obtain a Map of the required structure from a stream ( Stream API) and how to work with classifier functions ( Function) and predicates ( Predicate). In the end — a review of common mistakes.
    Available
  • Advanced aggregation: nested groupings

    JAVA 25 SELF
    Level 31, Lesson 3
    A hands-on dive into nested groupings with Streams and collectors: how to combine Collectors.groupingBy with aggregators ( maxBy, averagingInt, counting), transform data with mapping, split into subsets via partitioningBy, and correctly read nested Map structures. Lots of clear examples, visualization of result structures, and a breakdown of common mistakes.
    Available
  • Advanced collectors

    JAVA 25 SELF
    Level 31, Lesson 4
    In this lecture, we cover advanced Stream API collector techniques: nested downstream collectors for groupingBy/ partitioningBy, transformations with mapping, filtering with filtering, “flattening” with flatMapping, simultaneous aggregation with teeing (Java 12+), as well as “freezing” collections via toUnmodifiableList/Set/Map and collectingAndThen. We show practical pipelines and common pitfalls.
    Available
  • flatMap and mapMulti methods

    JAVA 25 SELF
    Level 32, Lesson 0
    In this lecture, we will figure out the difference between transforming data via map, “flattening” transformation via flatMap, and a more efficient analogue introduced in Java 16+ — mapMulti. With practical examples, we’ll clearly see how to unpack nested collections into Stream<String> instead of Stream<Stream<String>>, how to work with Optional via stream(), and when to choose mapMulti for performance without creating intermediate streams.
    Available
  • join, concat methods: merging streams

    JAVA 25 SELF
    Level 32, Lesson 1
    In this lecture, we examine ways to merge data in the Stream API: the static method Stream.concat for two streams, the combination of Stream.of + flatMap for an arbitrary number of streams, and the collector Collectors.joining for gluing elements into a single string. We will talk about laziness, the single-use nature of streams, order preservation, and common mistakes (reusing a stream, infinite streams, joining for non-strings) — with illustrative examples.
    Available
  • Union, intersection, and difference operations

    JAVA 25 SELF
    Level 32, Lesson 2
    In this lecture, we explore common set operations in Java: union ( union), intersection ( intersection), and difference ( difference) using the Set interface and the Stream API. We show practical examples with Stream.concat, Stream.of + flatMap, alternatives via retainAll/ removeAll, and important nuances about equals/ hashCode, performance, and common mistakes.
    Available
  • Zipping (zip), stream generation (iterate, generate)

    JAVA 25 SELF
    Level 32, Lesson 3
    In this lecture, we will discuss what zip is and why it is not in the standard Stream API (up to Java 22), learn how to “stitch” collections via indices using IntStream.range, as well as create streams on the fly using Stream.iterate and Stream.generate. Examples, visualisations, and typical mistakes will help you confidently apply generation and zipping in tasks.
    Available
  • Breakdown of common mistakes when working with streams

    JAVA 25 SELF
    Level 32, Lesson 4
    A detailed guide to common mistakes when working with the Stream API in Java: the single-use nature of a stream and repeated terminal operations ( collect(), forEach(), count()), modifying a collection during traversal, a forgotten limit() on infinite streams ( iterate, generate), handling null and working with Optional via flatMap(Optional::stream), preserving order with forEachOrdered(), efficient set operations with Set, proper resource closing ( Files.lines + try-with-resources), caution with parallelStream(), and the principle “until a terminal operation is invoked — nothing executes.” Every issue is accompanied by clear examples and fixes.
    Available
  • Primitive streams and the cost of boxing

    JAVA 25 SELF
    Level 33, Lesson 0
    In this lecture, we’ll look at why regular streams of numeric collections ( Stream<Integer>, Stream<Double>) can be inefficient due to boxing/unboxing, and how primitive streams — IntStream, LongStream, DoubleStream — help avoid it. We’ll cover conversions like mapToInt/ boxed(), aggregation operations ( sum(), average(), summaryStatistics()), safe results with OptionalInt/ OptionalDouble, as well as where optimization actually delivers gains and how to measure the effect with JMH.
    Available
  • Lazy evaluation in the Stream API

    JAVA 25 SELF
    Level 33, Lesson 1
    In this lecture, we explain how lazy evaluation works in the Stream API: how intermediate and terminal operations differ, why computations start only after a terminal is invoked, and what advantages per-element processing and “short-circuit evaluation” provide. We will show chains with filter, map, peek, findFirst, forEach, visualize how elements flow through the pipeline, and cover typical mistakes and recommendations for an efficient order of operations.
    Available
  • Immutable collections: Collections.unmodifiable

    JAVA 25 SELF
    Level 33, Lesson 2
    In this lecture, we examine how to protect data using immutable wrappers Collections.unmodifiableList, unmodifiableSet, unmodifiableMap; how “shallow” immutability differs from “deep” immutability; when and why to return wrappers from methods; and modern alternatives List.of/ Set.of/ Map.of. We will talk about typical mistakes (for example, expecting deep immutability or working with null) and why modification attempts end with UnsupportedOperationException.
    Available
  • Spliterator and parallel streams

    JAVA 25 SELF
    Level 33, Lesson 3
    In this lecture we break down what Spliterator is, how it allows not only iterating elements but also splitting the data source into parts using trySplit(), how parallel streams are built on top of this via parallelStream() and the common ForkJoinPool. We show the key methods ( tryAdvance, estimateSize, characteristics), typical characteristics ( ORDERED, SIZED, CONCURRENT, etc.), practical examples, a Mermaid diagram, and common mistakes when using parallel streams.
    Available
  • 1
  • ...
  • 14
  • 15
  • 16
  • 17
  • 18
  • ...
  • 30
Learn
  • Registration
  • Java Course
  • Help with Tasks
  • Pricing
  • Java Syntax
Community
  • Users
  • Articles
  • Forum
  • Chat
  • Success Stories
  • Activity
  • Affiliate Program
Company
  • About us
  • Contacts
  • Reviews
  • Press Room
  • CodeGym for EDU
  • FAQ
  • Support
CodeGym CodeGym is an online course for learning Java programming from scratch. This course is a perfect way to master Java for beginners. It contains 1200+ tasks with instant verification and an essential scope of Java fundamentals theory. To help you succeed in education, we’ve implemented a set of motivational features: quizzes, coding projects, content about efficient learning, and a Java developer’s career.
Follow us
Interface language
English
Deutsch Español हिन्दी Français Português Polski বাংলা 简体中文 मराठी தமிழ் Italiano Bahasa Indonesia 繁體中文 Nederlands 日本語 한국어 Bulgarian Danish Hungarian Basa Jawa Malay Norwegian Romanian Swedish Telugu Thai Українська Filipino Turkish Azərbaycan Русский Vietnamese
Programmers Are Made, Not Born © 2026 CodeGym
MastercardVisa
Programmers Are Made, Not Born © 2026 CodeGym