java 系统常量Const最优设计方法

java | 2021-04-29 10:52:48

每个项目设计常量类五花八门,所以再次强调最优得设计方式。

public interface Const{
	//单个
	String APP_NAME="";
	
	//一组
	enum DAY {  
        SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY  
    }
	
	//一组带状态
	enum COLOR {

		RED(0, "彩虹-红色"),

		ORANGE(1, "彩虹-橙色"),

		YELLEOW(2, "彩虹-黄色"),

		GREEN(3, "彩虹-绿色"),

		BLUE(4, "彩虹-蓝色");

		COLOR (int flag, String name) {

			this.flag = flag;

			this.name = name;

		}

		private int flag;

		private String name;

	}

}

 

登录后即可回复 登录 | 注册
    
关注编程学问公众号