• 枚举-enum


    package com.java.enums;
    
    public enum  UserTypeEnum {
    
        /**
         * UserTypeEnum  ROOT_ADMIN => ROOT_ADMIN.getName()...
         * UserTypeEnum  ADMIN => ADMIN.getName()...
         * UserTypeEnum  USER => USER.getName()...
         * UserTypeEnum valueOf(String enum) // 字符串转枚举
         * UserTypeEnum[] values()
         */
        ROOT_ADMIN("1", "超级管理员", "最高权限"),
        ADMIN("2", "管理员", "相关权限"),
        USER("3", "普通用户", "普通权限");
        private String name;
        private String code;
        private String desc;
        UserTypeEnum(String code, String name, String desc){
            this.code = code;
            this.name = name;
            this.desc = desc;
        }
        public String getName() {
            return name;
        }
    
        public String getCode() {
            return code;
        }
    
        public String getDesc() {
            return desc;
        }
    }
    
    class Demo {
        public static void main(String[] args) {
            UserTypeEnum[] values = UserTypeEnum.values();
            for (UserTypeEnum value : values) {
                System.out.println(value.getName() + " --- " + value.getCode() + " --- " + value.getDesc());
            }
        }
    }
    

      

  • 相关阅读:
    acm 总结之大数加法
    hdu 1004
    hdu 1887
    hdu 2007
    hdu 2004
    ACM总结之 A+B problem 总结
    nyoj_42_一笔画问题_201403181935
    最短路径--Floyd算法
    最短路径—Dijkstra算法
    nyoj_114_某种序列_201403161700
  • 原文地址:https://www.cnblogs.com/yuefeng123/p/11274624.html
Copyright © 2020-2023  润新知