package com.learningjava.conditionals;
public class SwitchExcercises {
public static boolean isWeekDay(int dayNumber) {
switch (dayNumber) {
case 0:
case 1:
case 2:
case 3:
case 4:
return true;
case 5:
case 6:
return false;
case default:
return false;
}
}
}
Run Code Online (Sandbox Code Playgroud)
我正在使用 Eclipse 作为我的 ide。说,在默认情况下显示错误
The preview feature Pattern Matching in Switch is only available with source level 20 and above.
Run Code Online (Sandbox Code Playgroud)
使用 java-se 17。感谢您的帮助。