# instanceof

say it: **“IN-stunts-uv”** **/ˈɪnstənsˌʌv/**

An operator that tests whether an object is compatible with a given type.

## What does **instanceof** do in Java?

**instanceof** — An operator that tests whether an object is compatible with a given type.

```java
class LabelReader {
    int lengthOf(Object value) {
        if (value instanceof String text) {
            return text.length();
        }

        return 0;
    }
}
```

Level: Journeyman · [More Java terms at this level](https://www.ask-codey.com/glossary?category=java&level=3)

Updated: November 17, 2026

## In other subjects

- [instanceof in JavaScript](https://www.ask-codey.com/glossary/instanceof-javascript)

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