class X { int switchTest1(Object obj) { return switch (obj) { case Integer i -> 3; case default -> 4; case null -> 10; case Point() -> 5; case Point(double x, double y) -> 6; case Point() point -> 7; case Point(double x, double y) point -> 8; }; } int switchTest2(int i) { return switch (i) { case Integer integer -> "int"; case Object obj -> "Object"; default -> "not ok"; }; } int switchTest2_2(Integer i) { return switch (i) { case int integer -> "int"; case Object obj -> "Object"; default -> "not ok"; }; } void switchTest3(Point point1, Point point2) { switch (point1) { case Point() -> {} } switch (point1) { case Point() point -> {} } switch (point1) { case Point() -> {} } switch (point1) { case Point() point -> {} } switch (point2) { case Point() -> {} } switch (point2) { case Point() point -> {} } } int instanceofTest(Object obj) { if (obj instanceof (Integer i && predicate())) { return 1; } if (obj instanceof (String s)) { return 3; } return 2; } void unconditionalGuardAndDefault(Object obj) { switch (obj) { case Object o when true -> {} default -> {} } } void dd6(String str) { switch (str) { case String i when i.length() == 2 -> System.out.println(2); case String i -> System.out.println(2); } } void dd7(String str) { switch (str) { case String i -> System.out.println(2); case String i when i.length() == 2 -> System.out.println(2); } } int testC(String str) { switch (str) { case String s when s.isEmpty()==true: return 1; case "": return -1; default: return 0; } } int testC2(String str) { switch (str) { case String s: return 1; case "": return -1; } } native static boolean predicate(); sealed interface I1 {} sealed interface I2 {} record R1() implements I1 {} record R2() implements I2 {} record R3() implements I1, I2 {}; public class Test22{ public void test(T c) { switch (c) { case R2 r1 -> System.out.println(5); case R3 r1 -> System.out.println(1); } } } }