Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumJavapattern matching switch instanceofSingle-choice MCQ

An if statement uses a NEGATED instanceof pattern with an early return. Is the binding s usable after the if, and why?

static String firstWord(Object o) { if (!(o instanceof String s)) return "n/a"; return s.split(" ")[0]; }