Java · Hard · Pro
Pattern matching for switch — handling null and dominance errors?
JavaJava 21+Senior
Pattern matching for switch
Switch can match types and patterns with guards. case null handles null explicitly; the compiler errors on dominance when a broader pattern shadows a narrower one.