[EnumEx1.java]
class ProductEx1{
public static void main(String[] args) {
Product p1 = new Product("En,Ca",7078);
Product p2 = new Product("En,Ca",7078);
System.out.println(p1 == p2);
System.out.println(p1.equals(p2));
System.out.println("p1 hashCode : "+p1.hashCode()+
" , p1 : "+p1);
System.out.println("p2 hashCode : "+p2.hashCode()+
" , p2 : "+p2);
}
}
[EnumEx2.java]
public class EnumEx1 {
public enum Lesson {
JAVA, XML, EJB
}
public static void main(String[] args) {
Lesson le = Lesson.JAVA;
System.out.println("Lesson : " + le);
System.out.println("XML : " + Lesson.XML);
}
}
[EnumEx3.java]
class EnumEx2 {
public enum Item{
Add, Del, Search, Cancel
}
public static void main(String[] args) {
Item a1 = Item.Search;
if (a1 instanceof Object){
System.out.println(a1.toString()+"^^");
System.out.println("OK! instanceof Object");
System.out.println("저장된 실제 정수값 : "+a1.ordinal());
}
Item[] items = Item.values();
System.out.println("items.length : "+items.length);
for(Item n : Item.values())
System.out.println(n+":"+n.ordinal());
}
}