import java.util.List; class Test { void testTypePattern1(Object o) { o = "fsd"; if (o instanceof String s) { System.out.println(); } } void testPattern2(Object o) { o = "fsd"; if (o instanceof Integer i) { System.out.println(); } } void testGuardedPattern1(Object o) { o = "fsd"; if (o instanceof String s && s.length() <= 3 && (s.length() > 1 || s.length() > 10)) { System.out.println(); } } void testGuardedPattern2(Object o) { o = "fsd"; if (o instanceof String s && s.length() < 3) { System.out.println(); } } void testParenthesizedPattern1(Object o) { o = "fsd"; if (o instanceof String s) { System.out.println(); } } void testParenthesizedPattern2(Object o) { o = "fsd"; if (o instanceof Integer i) { System.out.println(); } } void testInstanceofInForeach(List list) { for (Object obj : list) { if (obj instanceof String st) { } } } void testInstanceofTotalInForeach(List list) { for (Object obj : list) { if (obj instanceof Object st) { } } } private String getString() { return "str"; } }