-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJavaEnuminSwitch.java
More file actions
42 lines (39 loc) · 1.08 KB
/
JavaEnuminSwitch.java
File metadata and controls
42 lines (39 loc) · 1.08 KB
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
38
39
40
41
42
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package oops;
/**
*
* @author Sunil shetty
*/
enum Level{
Low,High,Medium
}
public class JavaEnuminSwitch {
public static void main(String[]args)
{
Level lev = Level.Medium;
switch(lev)
{
case Low:
System.out.println("Low level");
break;
case Medium:
System.out.println("Medium level");
break;
case High:
System.out.println("High level");
break;
}
//loop through enum
System.out.println("----------------------------------------------------");
System.out.println("For Loop");
System.out.println("----------------------------------------------------");
for(Level myvar:Level.values())
{
System.out.println(myvar);
}
}
}