「C++」enumを使って文字列で複数条件を利用するサンプル
サンプルコード
public enum Fruit { APPLE, BANANA, ORANGE, WATERMELON } public class EnumTest { public static void main(String[] args) { for(Fruit fruit : Fruit.values()) { cftFun(fruit); } } public static void cftFun(Fruit fruit) { switch (fruit) { case APPLE: System.out.println("This is an apple"); break; case BANANA: System.out.println("This is a banana"); break; case ORANGE: System.out.println("This is an orange"); break; case WATERMELON: System.out.println("This is a watermelon"); break; default: break; } } }