我有这个枚举:
public class RemoteUnitType implements Serializable {
public enum deviceVersion {
ANDROID_AT1,
ANDROID_AT1_PRO,
ANDROID_AT5,
ANDROID_AK1
}
我想在枚举上创建一个开关,就像这样
switch (remoteUnit.getDeviceVersion()) {
case RemoteUnitType.deviceVersion.ANDROID_AK1 :
break;
}
但我收到了这个错误:
The qualified case label RemoteUnitType.deviceVersion.ANDROID_AK1 must be replaced with the unqualified enum constant
最佳答案
您不需要限定,只需使用枚举的标签:
switch (remoteUnit.getDeviceVersion()) {
case ANDROID_AK1 :
break;
}
关于java - 在 Java 中打开枚举 : unqualified enum constant,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46241418/