Java examples for Language Basics:enum
Enum Type Implementing the Command Interface
enum CommandList implements Command { RUN {/* w w w .j av a2s .com*/ public void execute() { System.out.println("Running..."); } }, JUMP { public void execute() { System.out.println("Jumping..."); } }; public abstract void execute(); } interface Command { void execute(); } public class Main { public static void main(String... args) { for (Command cmd : CommandList.values()) { cmd.execute(); } } }