I am a bit curious about how values() method works in Enum type in Java. As seen in Java Specification Document, we can iterate over all values of a certain enum type in a for each loop. e.g.
for (Planet p : Planet.values()) {
System.out.printf("Your weight on %s is %f%n",
p, p.surfaceWeight(mass));
}
I think for each loop iterate over all values. In this call we are calling a method repeatedly in each loop call so how will it iterate over all enum type or values() method employ iterator of some sort. Can anybody help me with the documentation of implementation of this method?