Skip to lesson

Build a Product & Customer Catalogue

Two objects with the same data are still two objects: == asks "is this the same object?", while a good equals() asks "is this the same product?".

What you will learn

What you will learn

  • Override equals, hashCode and toString together in Java
  • Compare objects by a key field with Objects.equals and Objects.hash
  • Detect duplicates and search an array with equals
  • Explain the difference between == and equals with a real program

Sign in to continue this lesson

Create an account to read every lesson, practise with the exercises and keep track of your progress.