Files
2020-05-13 07:43:16 +00:00

21 lines
502 B
Java

import java.util.OptionalInt;
import java.util.Random;
class OptionalIntSwitch {
// IDEA-240631
public static void main(String[] args) {
OptionalInt opt = OptionalInt.of(new Random().nextInt() % 2);
switch (opt.getAsInt()) {
case 0:
System.out.println("zero");
break;
case 1:
System.out.println("one");
break;
case <warning descr="Switch label '2' is unreachable">2</warning>:
System.out.println("two");
break;
}
}
}