MCPcopy Index your code
hub / github.com/BruceEckel/OnJava8-Examples / main

Method main

enums/EnumClass.java:10–30  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

8
9public class EnumClass {
10 public static void main(String[] args) {
11 for(Shrubbery s : Shrubbery.values()) {
12 System.out.println(
13 s + " ordinal: " + s.ordinal());
14 System.out.print(
15 s.compareTo(Shrubbery.CRAWLING) + " ");
16 System.out.print(
17 s.equals(Shrubbery.CRAWLING) + " ");
18 System.out.println(s == Shrubbery.CRAWLING);
19 System.out.println(s.getDeclaringClass());
20 System.out.println(s.name());
21 System.out.println("********************");
22 }
23 // Produce an enum value from a String name:
24 for(String s :
25 "HANGING CRAWLING GROUND".split(" ")) {
26 Shrubbery shrub =
27 Enum.valueOf(Shrubbery.class, s);
28 System.out.println(shrub);
29 }
30 }
31}
32/* Output:
33GROUND ordinal: 0

Callers

nothing calls this directly

Calls 6

valuesMethod · 0.80
printMethod · 0.80
splitMethod · 0.80
nameMethod · 0.65
compareToMethod · 0.45
equalsMethod · 0.45

Tested by

no test coverage detected