ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
>[success] # switch 使用枚举 * 定义枚举 ~~~ public enum EnumDirection { UP, DOWN, LEFT, RIGHT, } ~~~ * 使用枚举 ~~~ public class App { public static void show(EnumDirection ed) { switch (ed) { case UP: System.out.println("1"); break; case DOWN: System.out.println("2"); break; case LEFT: System.out.println("3"); break; case RIGHT: System.out.println("4"); break; default: System.out.println("5"); } } public static void main(String[] args) { App.show(EnumDirection.UP); } } ~~~