instanceof
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.
class LabelReader {
int lengthOf(Object value) {
if (value instanceof String text) {
return text.length();
}
return 0;
}
}
Level: Journeyman · More Java terms at this level
Updated