This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Can't find the method values() used for enums. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Can Watch "Can New topic

Can't find the method values() used for enums.

Nikolaos Plastiras

Joined: Feb 08, 2012
Posts: 7

I am trying to find the static values() method that is used to iterate through enums in J2SE 6 documentation but I can't find it.
Is this the correct class?
public abstract class Enum<E extends Enum<E>> extends Object implements Comparable<E>, Serializable
Emanuel Kadziela
Ranch Hand

Joined: Mar 24, 2005
Posts: 186
it's not the Enum class, its the enum keyword, like this:

Rob Spoor

Joined: Oct 27, 2005
Posts: 19649

The values() method gets generated automatically for all enum classes. You can find it in the specific enum Javadoc page. For example check out TimeUnit.

How To Ask Questions How To Answer Questions
Joanne Neal

Joined: Aug 05, 2005
Posts: 3415
It does get a mention in the Enum javadoc, but not as a separate method, just as an aside in the description of the valueOf method.

I agree. Here's the link:
subject: Can't find the method values() used for enums.
Similar Threads
SCJP 5: Q on enums
Cannot understand enum class syntax
Iterating through unknown enum type variable
enum in Tiger
Getting a random element from an Enum