Help the world stop coronavirus! Stay home!

Prev Next

Java / Control Statements

Can you create switch statement using enum?

Yes.

public class EnumSwitchCaseExample {

	enum Communication {
		EMAIL, CHAT, PHONECALL, MESSAGE
	}

	public static void main(String[] args) {

		Communication mode = Communication.CHAT;
		switch (mode) {
		case EMAIL:
			System.out.println("Communicated by Email.");
			break;
		case CHAT:
			System.out.println("Communicated by Instant messaging.");
			break;
		case PHONECALL:
			System.out.println("Communicated by Voice call.");
			break;
		case MESSAGE:
			System.out.println("Communicated by Message.");
			break;
		}
	}
}

❤Cash Back At Stores you Love !!!❤

Earn your $10 reward when you make your first purchase through Ebates by signing up with clicking below button.

Ebates Coupons and Cash Back

More Related questions...

Show more question and Answers...

Access Modifiers

Comments & Discussions