-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnumDemo.java
More file actions
37 lines (31 loc) · 985 Bytes
/
EnumDemo.java
File metadata and controls
37 lines (31 loc) · 985 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
26
27
28
29
30
31
32
33
34
35
36
37
enum Transport {
CAR, TRUCK, AIRPLANE, TRAIN, BOAT
}
class EnumDemo {
public static void main(String args[]) {
Transport tp;
tp = Transport.AIRPLANE;
System.out.println("Value of tp: " + tp);
System.out.println();
tp = Transport.TRAIN;
if(tp == Transport.TRAIN)
System.out.println("tp equals to TRAIN\n");
switch(tp) {
case CAR:
System.out.println("CAR transfer people");
break;
case TRUCK:
System.out.println("TRUCK transfer cargo");
break;
case AIRPLANE:
System.out.println("AIRPLANE flys");
break;
case TRAIN:
System.out.println("TRAIN rides on rails");
break;
case BOAT:
System.out.println("BOAT floats on water");
break;
}
}
}