# toString()

A method that returns a readable text representation of an object.

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

**toString()** — A method that returns a readable text representation of an object.

```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

## In other subjects

- [ToString() in C#](https://www.ask-codey.com/glossary/tostring-c-sharp)
- [toString() in JavaScript](https://www.ask-codey.com/glossary/tostring-javascript)

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