개발/자바
-
[자바/java] enum 열거형개발/자바 2021. 3. 29. 17:58
- 상수 열거형 클래스 - 다양한 메소드 지원, 소스간결화, 뚜렷한 목적성 등등 - 클래스 내부, 외부, 별도 정의 모두 가능 public enum BoardType { notice, free; } public void main(String args[]){ BoardType type = BoardType.free; System.out.println(type); } -> 기본적인 사용법, 당연히 정의해 놓은 notice나 free만 가능하다 public enum BoardType { notice("공지사항"), //생성자 스스로 호출 free("자유게시판"); private String value; BoardType(String value){ this.value = value; } public String..