What is pattern matching for switch (Java 21)?
Instead of if (obj instanceof String s) { ... }, use switch (obj) { case String s when s.length() > 5 -> ...; case String s -> ...; case null -> ...;...
What is pattern matching for switch (Java 21)? · Home · Support the platform