Java switch 使用枚举类
开发过程中为了代码的可阅读性和可维护性,很多类型字段往往会习惯使用枚举去定义,可是在一些判断里面想用switch去代替if else 就会出现以下问题public enum SexType { MAN(1, "男"), GIRL(2, "女"), ; private int type; private String work; SexType(int type, String work) { this.type = type;
原创
2020-10-17 15:54:02 ·
6625 阅读 ·
2 评论