-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnum.java
More file actions
39 lines (36 loc) · 965 Bytes
/
Enum.java
File metadata and controls
39 lines (36 loc) · 965 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
38
39
package JavaLangPackage;
enum Dept{
CSA("Allen","Paris"),
IT("Octave","USA"),
EC("Bell","Sydney"),
ME("Micheal","Manchester"),
CE("linus","Ohio");
//finals and In Caps
String Name;
String Address;
Dept(String Name, String Address){
this.Name = Name;
this.Address = Address;
System.out.println(this.name()+"["+this.ordinal()+"]");
}
public void display(){
System.out.println("Name: "+Name);
System.out.println("Address: "+Address);
}
}
public class Enum {
public static void main(String[] args) {
Dept d = Dept.CSA;
System.out.println(d.name());
System.out.println(d);
System.out.println(d.ordinal());
System.out.println(Dept.valueOf("ME"));
Dept[] List = Dept.values();
for (Dept x: List) {
x.display();
}
for (Dept x: List) {
System.out.println(" " + x);
}
}
}