作者:手机用户2502880437 | 来源:互联网 | 2023-05-17 12:12
TypeEnumtypeEnumTypeEnum.values()[type-1];switch(typeEnum){caseUSED:doSomething1();brea
// ...TypeEnum typeEnum = TypeEnum.values()[type - 1];switch (typeEnum) {case USED:doSomething1();break;case UNUSED:doSomething2();break;default:doSomething3();break;}
注意case上使用的是枚举类型,不需要加枚举类类名;而switch输入枚举类实例。当然,type-1那里需要先判断条件是否符合。