我想问一下我在使用ENUM时是否必须在开关中填写“默认”并在if语句中填写“ else”?
换句话说,可以编写如下部分代码:
enum Color {
RED, BLUE
}
void whatColor(Color c) {
if(c == Color.RED) {
System.out.println("It's red");
} else {
System.out.println("It's blue");
阿波罗的战车
相关分类