# hashCode()

A method that produces an integer used by hash-based collections.

## What does **hashCode()** do in Java?

**hashCode()** — A method that produces an integer used by hash-based collections.

```java
record Product(String name) {
}

class ProductCheck {
    boolean sameProduct(Product first, Product second) {
        return first.equals(second);
    }
}
```

Level: Journeyman · [More Java terms at this level](https://www.ask-codey.com/glossary/subjects/java/journeyman)

Updated: September 27, 2026

Source: https://www.ask-codey.com/glossary/hashcode
