/* * enum and switch in Java. * One of the most natural uses of switch is with enum * @author gtowell * created: July 30, 2021 */ /* * Enum list all of the possible values of a type */ enum Suits { CLUBS, DIAMONDS, HEARTS, SPADES }; public class Switch { public static void main(String[] args) { Suits a3 = Suits.CLUBS; switch (a3) { // note the warnign when the swict does not cover all cases of enum case SPADES: System.out.println("aa"); break; case HEARTS: System.out.println("cc"); case DIAMONDS: System.out.println("DIA"); break; } } }