class X { void expressions(Object obj) { if (obj instanceof String s) { s = "foo"; } if (obj instanceof final String s) { s = "foo"; } } }