class X { void test(Object obj) { if (obj instanceof String a) { System.out.println(a.length()); } } }