美文网首页
Java枚举犯的错误

Java枚举犯的错误

作者: Danny_Boy | 来源:发表于2017-12-20 16:22 被阅读4次
    public enum CustomerGender {
        Gender, Male, Female, UNKNOWN;
    
        public static CustomerGender fromString(String gender) {
            for (CustomerGender customerGender : CustomerGender.values()) {
                if (customerGender.name().equals(gender)) {
                    return customerGender;
                }
            }
    
            return UNKNOWN;
        }
    }
    

    相关文章

      网友评论

          本文标题:Java枚举犯的错误

          本文链接:https://www.haomeiwen.com/subject/bfggwxtx.html