2015-04-20 15:36:01 -07:00
|
|
|
|
//: enumerated/UpcastEnum.java
|
2015-05-29 14:18:51 -07:00
|
|
|
|
// <20>2015 MindView LLC: see Copyright.txt
|
2015-04-20 15:36:01 -07:00
|
|
|
|
// No values() method if you upcast an enum
|
|
|
|
|
|
|
|
|
|
enum Search { HITHER, YON }
|
|
|
|
|
|
|
|
|
|
public class UpcastEnum {
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
Search[] vals = Search.values();
|
|
|
|
|
Enum e = Search.HITHER; // Upcast
|
|
|
|
|
// e.values(); // No values() in Enum
|
|
|
|
|
for(Enum en : e.getClass().getEnumConstants())
|
|
|
|
|
System.out.println(en);
|
|
|
|
|
}
|
|
|
|
|
} /* Output:
|
|
|
|
|
HITHER
|
|
|
|
|
YON
|
|
|
|
|
*///:~
|