public class GuardBeforeGeneral { static String f(Object o) { return switch (o) { case String s -> "any string"; case String s when s.isEmpty() -> "empty string"; // guarded case after the unguarded one default -> "other"; }; } public static void main(String[] args) { System.out.println(f("")); } }