java.io.Serializable
, and java.lang.Comparable
.public enum Color implements Runnable { WHITE, BLACK, RED, YELLOW, BLUE; public void run() { System.out.println("name()=" + name() + ", toString()=" + toString()); } }A sample test program to invoke this run() method:
for(Color c : Color.values()) { c.run(); }Or,
for(Runnable r : Color.values()) {
r.run();
}
No comments:
Post a Comment