diff options
Diffstat (limited to 'tests/features199/java18/SwitchPatternPreview2Error1.java')
-rw-r--r-- | tests/features199/java18/SwitchPatternPreview2Error1.java | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/features199/java18/SwitchPatternPreview2Error1.java b/tests/features199/java18/SwitchPatternPreview2Error1.java new file mode 100644 index 000000000..342b848aa --- /dev/null +++ b/tests/features199/java18/SwitchPatternPreview2Error1.java @@ -0,0 +1,13 @@ +/** + * Inspired by examples in https://openjdk.java.net/jeps/420 + */ +public class SwitchPatternPreview2Error1 { + static void constantLabelsMustAppearBeforePatterns1(Integer i) { + switch (i) { + case null -> System.out.println("value unavailable: " + i); + case Integer value && value > 0 -> System.out.println("positive integer: " + i); + case -1, 1 -> System.out.println("absolute value 1: " + i); + default -> System.out.println("other integer: " + i); + } + } +} |