enum
Posted 2015. 4. 10. 15:51package chap10;
// 열거형 예제
public class EnumEx1 {
public enum Lesson{
JAVA, XML, EJB, JSP, SPRING
}
public static void main(String[] args) {
Lesson le = Lesson.JAVA;
System.out.println("Lesson :" + le);
System.out.println("XML :" + Lesson.XML);
System.out.println("JSP :" + Lesson.JSP);
System.out.println("SPRING :" + Lesson.SPRING);
//le 객체다
if( le instanceof Object ){
System.out.println(le.toString());
System.out.println(le.getClass().getName());
System.out.println("저장된 정수값:" + le.ordinal());
}
Lesson[] lessons = Lesson.values();
System.out.println("lesson.length =" + lessons.length);
for( Lesson n : lessons ){
System.out.println(n + ":" + n.ordinal() );
}
}
}
'Java !!!' 카테고리의 다른 글
innerClass_Ex3 (0) | 2015.04.10 |
---|---|
innerClass_Ex2 (0) | 2015.04.10 |
Collection_EX (0) | 2015.04.10 |
Collection _ArrayList (0) | 2015.04.10 |
Collection _Iterator (0) | 2015.04.10 |
- Filed under : Java !!!