관리 메뉴

취미개발 블로그와 마음수양

자바 enum 본문

Language

자바 enum

아라한사 2014. 8. 4. 15:52



public enum Level {

GOLD(3, null), SILVER(2, GOLD), BASIC(1, SILVER);

 

private final int value;

private final Level next;


Level(int value, Level next) {

this.value = value;

this.next = next;

}


public int intValue() {

return value;

}


public Level nextLevel() {

return this.next;

}


public static Level valueOf(int value) {

switch (value) {

case 1:

return BASIC;

case 2:

return SILVER;

case 3:

return GOLD;

default:

throw new AssertionError("Unknown value : " + value);

}

}


}



'Language' 카테고리의 다른 글

Java beans, VO, DTO, POJO  (0) 2016.10.08
눈 내리는 자바 소스  (0) 2014.08.13
날짜 오늘 날짜 변환 공식  (0) 2014.06.06
ip주소 중간중간에 하트로표시해주기.  (0) 2014.05.31
자바 동적 바인딩에 관하여~  (0) 2014.04.17