I've installed jdk 17 and try to compile this code:
private static String getText(int number) {
return switch (number) {
case 1, 2 -> yield "one or two";
case 3 -> yield "three";
case 4, 5, 6 -> yield "four or five or six";
default -> yield "unknown";
};
}
It doesn't compile, if I remove the yield
keyword, then it gets compile. Where does the code get wrong?