-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnumClass.java
More file actions
23 lines (22 loc) · 784 Bytes
/
EnumClass.java
File metadata and controls
23 lines (22 loc) · 784 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
enum Shrubbery {
GROUND,
CRAWLING,
HANGING
}
public class EnumClass {
public static void main(String[] args) {
for (Shrubbery s : Shrubbery.values()) {
System.out.println(s + " ordinal: " + s.ordinal());
System.out.println(s.compareTo(Shrubbery.CRAWLING) + " ");
System.out.println(s.equals(Shrubbery.CRAWLING) + " ");
System.out.println(s == Shrubbery.CRAWLING);
System.out.println(s.getDeclaringClass());
System.out.println(s.name());
System.out.println("----------------------");
}
for (String s: "HANGING CRAWLING GROUND".split(" ")){
Shrubbery shrub = Enum.valueOf(Shrubbery.class, s);
System.out.println(shrub);
}
}
}