You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SwitchPatternPreview3Error1.java 489B

12345678910111213
  1. /**
  2. * Inspired by examples in https://openjdk.java.net/jeps/420
  3. */
  4. public class SwitchPatternPreview3Error1 {
  5. static void constantLabelsMustAppearBeforePatterns1(Integer i) {
  6. switch (i) {
  7. case null -> System.out.println("value unavailable: " + i);
  8. case Integer value when value > 0 -> System.out.println("positive integer: " + i);
  9. case -1, 1 -> System.out.println("absolute value 1: " + i);
  10. default -> System.out.println("other integer: " + i);
  11. }
  12. }
  13. }