java 枚举的用法

public enum  StatisticTableEnum {

	DOC_BROWSE_STATISTIC("doc_browse_statistic"),
	DOC_LIB_BROWSE_STATISTIC("doc_lib_browse_statistic"),
	SEARCH_KEY_STATISTIC("search_key_statistic"),
	SEARCH_STATISTIC("search_statistic"),
	USER_COLLECT_STATISTIC("user_collect_statistic"),
	USER_COMMENT_STATISTIC("user_comment_statistic"),
	USER_NOTE_STATISTIC("user_note_statistic"),
	USER_STATISTIC("user_statistic");
	private String tableName;

	StatisticTableEnum(String tableName) {
		this.tableName = tableName;
	}

	public String getTableName() {
		return tableName;
	}
}

  代码中直接调用时就已经进行了构造函数的初始化:

StatisticTableEnum.DOC_LIB_BROWSE_STATISTIC.getTableName()

http://www.runoob.com/java/method-enum1.html

 


posted @ 2018-06-27 17:43  Andrew_F  阅读(193)  评论(0编辑  收藏  举报