aboutsummaryrefslogtreecommitdiffstats
path: root/tests/features199/java18/SwitchPatternPreview2Error1.java
blob: 342b848aa8cf21a9f7360574a9abdc4b1951064b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
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);
    }
  }
}