é²å¾¡çããã°ã©ãã³ã°ã§ã¯ãå¤é¨ããã®å¼ã³åºãããé²å¾¡ãã¾ãããããããã以å¤ã«ãèªåèªèº«ã®èª¤ãã«å¯¾ãã¦é²å¾¡ããã¨ãããã¨ãããã¾ãã 次ã®ã³ã¼ãã¯ããEffective Java 第2çãï¼p.147ï¼ã«æ²è¼ããã¦ããã³ã¼ãã§ãã// å¤ã«ãã£ã¦åãæ¿ããenum å- åé¡ãå¤ã public enum Operation { PLUS, MINUS, TIMES, DIVIDE; // å®æ°ã§è¡¨ãããç®è¡æä½ãè¡ã double apply(double x, double y) { switch(this) { case PLUS: return x + y; case MINUS: return x - y; case TIMES: return x * y; case DIVIDE: return x / y; } throw new AssertionError("Unknow
{{#tags}}- {{label}}
{{/tags}}