forked from foojayio/getting_started_with_java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnumSwitch.java
More file actions
25 lines (23 loc) · 808 Bytes
/
Copy pathEnumSwitch.java
File metadata and controls
25 lines (23 loc) · 808 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
public class EnumSwitch {
public static void main (String[] args) {
// Define value based on an enum
TestOption option = TestOption.TYPE_5;
// Compare the value with the available options
switch(option) {
case TYPE_1:
System.out.println("Do something specific for Type 1");
break;
case TYPE_2:
System.out.println("Do something specific for Type 2");
break;
case TYPE_3:
System.out.println("Do something specific for Type 3");
break;
default:
System.out.println("No action defined for this type: " + option);
}
}
enum TestOption {
TYPE_1, TYPE_2, TYPE_3, TYPE_4, TYPE_5, UNKNOWN;
}
}