class Test { int testIncomplete(Object obj) { return switch(obj) { case String s when }; } void test1(Object o) { int a; switch (o) { case String s: { if (s == null) { System.out.println(); } a = -1; break; } default: { a = 2; break; } } if (a < 0) { System.out.println(a); } } void test2(Object o) { int a; switch (o) { case String s: { if (s instanceof CharSequence) { System.out.println(s); } a = 1; break; } default: { a = 2; break; } } if (a < 0) { System.out.println(a); } } final String FSD = "fsd"; int test3() { return switch(FSD) { case String s when s.length() <= 3 && (s.length() > 1 || s.length() > 10) -> 1; case String s when Math.random() > 0.5 -> 2; default -> 3; }; } int test4(String s) { s = FSD; return switch (s) { case String ss when (ss.length() < 3 || ss.length() == 4) -> 1; case String ss -> 2; }; } void test5() { switch (FSD) { case String s when s.length() > 2 && s.length() < 3 -> System.out.println(1); case String s when s.isEmpty() -> 2; default -> System.out.println(3); }; } void test6() { String s = "abc"; switch (s) { case Object o -> System.out.println("total"); } } void test7() { String s = "abc"; switch (s) { case Object o -> System.out.println("total"); default -> System.out.println("default"); } } void test8() { String s = "abc"; switch (s) { case "" -> System.out.println("abc"); case Object o -> System.out.println("total"); default -> System.out.println("default"); } } void test9() { String s = "abc"; switch (s) { case Object o -> System.out.println("total"); case "abc" -> System.out.println("abc"); } } }