CodeGym
Promotion
CodeGym University
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
  • equals and hashCode contracts

    JAVA 25 SELF
    Level 29, Lesson 0
    In this lecture, we will break down how to correctly define object equality in Java: how reference comparison with the == operator differs from content comparison with the equals method, why the equals/ hashCode contract is critical for collections like HashSet and HashMap, and how to relate this to compareTo from Comparable. Step-by-step examples, best practices, and a review of common mistakes will help you avoid pitfalls when working with hash tables and sorted collections.
    Available
  • The Objects class: equals, hashCode, hash methods

    JAVA 25 SELF
    Level 29, Lesson 1
    In this lecture we break down the “Swiss Army knife” java.util.Objects: how to compare safely with Objects.equals, compute hashes concisely with Objects.hash, delegate comparison via Objects.compare, enforce non- null values with Objects.requireNonNull, and use Objects.isNull/ Objects.nonNull in streams. We’ll show a correct implementation of equals/ hashCode/ compareTo, and go through practical cases and common mistakes when working with HashMap/ HashSet.
    Available
  • Comparable interface: implementation, compareTo

    JAVA 25 SELF
    Level 29, Lesson 2
    In this lecture we explore the natural ordering of objects in Java via the Comparable interface and the compareTo method: why it is needed, how to implement it correctly, how collection sorting works ( Collections.sort and List.sort), multi-field comparison, handling null values, and consistency with equals/ hashCode. We will cover best practices, common mistakes, and practical examples with the Person class.
    Available
  • Comparator Interface: Creation and Usage

    JAVA 25 SELF
    Level 29, Lesson 3
    In this lecture, we discuss when to use Comparator instead of Comparable, the syntax and contract of the method compare(T o1, T o2), hands-on list sorting with Collections.sort and List.sort, and creating comparators as separate classes as well as via anonymous classes and lambda expressions. We will look at multi-level sorting, working with null values, searching via Collections.binarySearch, reversing order with reversed(), as well as best practices and common mistakes (for example, why it’s better to use Integer.compare rather than a - b).
    Available
  • Searching and sorting elements in Java collections

    JAVA 25 SELF
    Level 29, Lesson 4
    In this lecture, we’ll cover practical techniques for working with collections: searching for elements using contains, indexOf, lastIndexOf, conditional search with a for loop and the break statement, finding the minimum and maximum with the Collections class. We’ll practice sorting lists with Collections.sort and List.sort, using a Comparator, sorting key–value pairs from a Map, as well as sorting objects by a field. Finally, we’ll discuss common pitfalls: immutable lists from List.of, attempts to sort a Set/ Map, and incorrect comparators.
    Available
  • Introduction to the Stream API: why you need streams

    JAVA 25 SELF
    Level 30, Lesson 0
    In this lecture we explore why the imperative approach to processing collections quickly accumulates boilerplate, and how the Stream API shifts code to a declarative style: chains of operations like filter, map, collect, simple composition, fewer mistakes, and easy parallelism via parallelStream(). We will cover use cases, the history of the feature, and common pitfalls to avoid.
    Available
  • Basic Stream API operations: map, filter, collect

    JAVA 25 SELF
    Level 30, Lesson 1
    A step-by-step introduction to the basic Stream API operations: how to get a stream from a collection and an array ( stream(), Arrays.stream, Stream.of), how intermediate operations ( filter, map, distinct) differ from terminal ones ( collect, forEach, count), and how to collect results using Collectors ( toList, toSet, joining). Practical examples, mini‑tasks, and a section on common mistakes will help you quickly master pipeline processing of data.
    Available
  • Stream API subsets: distinct, limit, skip

    JAVA 25 SELF
    Level 30, Lesson 2
    In this lecture, we break down three key Stream API operations for working with data subsets: distinct (removing duplicates), limit (restricting the number of elements), and skip (skipping the first elements). You will see how they work on collections of strings and objects, how the implementation of equals/ hashCode affects the result of distinct, how to combine operations for pagination and top‑N selection, and which mistakes occur most often.
    Available
  • forEach and peek methods: side effects

    JAVA 25 SELF
    Level 30, Lesson 3
    In this lecture, we cover stream operations for side effects: the terminal forEach and the intermediate peek. We’ll understand when and why to use them, how they differ, why after forEach the stream “closes”, while peek doesn’t change data and runs only when there’s a terminal operation. We’ll show practical examples, discuss non-obvious points, and typical mistakes (including ConcurrentModificationException and incorrectly replacing collect with forEach).
    Available
  • Transforming Collections with Streams

    JAVA 25 SELF
    Level 30, Lesson 4
    A practical guide to transforming collections using Stream API: converting List ↔ Set, building maps via Collectors.toMap() (including handling duplicates), joining into a string with Collectors.joining(), and a breakdown of terminal and intermediate operations ( forEach, collect, count, anyMatch, etc.). Inside, you’ll find clear examples, explanations, and common mistakes.
    Available
  • sum, count, average, max, min methods in the Stream API

    JAVA 25 SELF
    Level 31, Lesson 0
    In this lecture, we cover aggregating operations in the Stream API: how to count with count(), compute sums and averages with primitive streams ( IntStream, LongStream, DoubleStream) and the methods sum(), average(), as well as how to find extrema via min()/ max(). We will also discuss working with the containers Optional, OptionalInt, OptionalLong, OptionalDouble and the right ways to extract values: orElse(...), ifPresent(...), orElseThrow(). You’ll learn to use collectors like Collectors.summingInt, Collectors.averagingInt, Collectors.maxBy/ minBy and combine them with groupingBy. At the end—an overview of common mistakes and nuances.
    Available
  • Reduce and collect methods: data aggregation

    JAVA 25 SELF
    Level 31, Lesson 1
    We break down terminal stream operations: the universal reduction reduce() and the powerful collector collect(). We’ll understand the signatures with identity, accumulator, and combiner, learn to assemble data using ready-made collectors from Collectors ( toList(), toMap(), joining(), groupingBy()) and see where you should prefer collect() over reduce(). We’ll also discuss working with Optional, handling duplicates in toMap(), and nuances of parallel streams.
    Available
  • 1
  • ...
  • 13
  • 14
  • 15
  • 16
  • 17
  • ...
  • 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