JavaRush
AI Academy
new
Promotion
Learning
Courses
Tasks
Quizzes
Games
Help
Schedule of nudges
Internship
Community
Users
Forum
Chat
Articles
Activities
Reviews
Subscriptions
Light theme

Lectures

  • Reviews
  • About us
  • CS50
Start
Start learning
Start learning
  • My progress
  • Courses
  • Quest map
  • Lectures
  • equals and hashCode contracts

    JAVA 25 SELF
    29 level,0 lecture
    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.
    Open
  • The Objects class: equals, hashCode, hash methods

    JAVA 25 SELF
    29 level,1 lecture
    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.
    Open
  • Comparable interface: implementation, compareTo

    JAVA 25 SELF
    29 level,2 lecture
    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.
    Open
  • Comparator Interface: Creation and Usage

    JAVA 25 SELF
    29 level,3 lecture
    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).
    Open
  • Searching and sorting elements in Java collections

    JAVA 25 SELF
    29 level,4 lecture
    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.
    Open
Courses
  • Java Course
  • Python Course
  • Development with Claude Code
  • All 16 courses
University
  • Java FullStack
  • Python FullStack
  • AI Native Developer
  • Web FullStack
Community
  • Articles
  • Forum
  • Help with Tasks
Company
  • About us
  • Contacts
  • Reviews
  • Pricing
  • Questions and answers
JavaRush JavaRush: online courses in Java and other programming languages, where you learn by solving tasks. We started in 2012 with a Java course, and today there are 16 courses: Java and Spring, Python, web development, SQL, Go, C#, C++, Kotlin, Swift, Docker and AI development. More than 10,000 tasks with instant checks, and the first level of any course is free. Learn on your own or with a mentor at JavaRush University.
Follow us
Язык интерфейса
Русский
English
Українська
"Programmers are not born" © 2026 JavaRush Terms of Use and Privacy policy
MastercardVisa
"Programmers are not born" © 2026 JavaRush Terms of Use and Privacy policy