Enum Types Tutorial wrote:
Java programming language enum types are much more powerful than their counterparts in other languages. The enum declaration defines a class (called an enum type). The enum class body can include methods and other fields. The compiler automatically adds some special methods when it creates an enum. For example, they have a static values method that returns an array containing all of the values of the enum in the order they are declared. This method is commonly used in combination with the for-each construct to iterate over the values of an enum type.
Now that we've established that the values() method returns an array, take a look at the two code samples you provided and look at how they handle the return value of the call to the values() method. Can you explain what's happening in either case?
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
posted 5 years ago
Now when you say it like that, i feel so stupid
Q7 is just printing the array reference and in the example, we are iterating over the array returned by .values()