6 lines
330 B
Java
6 lines
330 B
Java
/** Fails on 17 without --enable-preview: pattern matching for switch is only a preview feature in 17 (JEP 406). */
|
|
public class SwitchPatternOn17 {
|
|
static String f(Object o) { return switch (o) { case String s -> "string"; default -> "other"; }; }
|
|
public static void main(String[] args) { System.out.println(f("x")); }
|
|
}
|