Using notation like:
---
o instanceof String s
//s declared here iff the above evaluates to true
---
or possibly
---
if (!(o instanceof String s)) throw new IllegalStateException();
//s declared here iff the above didn't throw an exception
---
---
o instanceof String s
//s declared here iff the above evaluates to true
---
or possibly
---
if (!(o instanceof String s)) throw new IllegalStateException();
//s declared here iff the above didn't throw an exception
---