File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Where are these methods documented Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Where are these methods documented" Watch "Where are these methods documented" New topic
Author

Where are these methods documented

Harsh Pensi
Ranch Hand

Joined: Aug 05, 2009
Posts: 67
Q.1. I'm not able to find the static values() method and the valueOf(String s) method for enums in the java.lang.Enum<E> specification. Where is this documented?

Q.2. Also, can we run the main method inside an enum as in code below?


SCJP6 - 93% SCWCD5 - 97%
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41108
    
  45
As to #1, start here: http://java.sun.com/docs/books/tutorial/reflect/special/enum.html

As to #2, what happened when you tried?


Ping & DNS - my free Android networking tools app
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Murtuza Arzai wrote:Q.1. I'm not able to find the static values() method and the valueOf(String s) method for enums in the java.lang.Enum<E> specification. Where is this documented?

In the Java Language Specification


[My Blog]
All roads lead to JavaRanch
Harsh Pensi
Ranch Hand

Joined: Aug 05, 2009
Posts: 67
Ulf Dittmer wrote:
As to #2, what happened when you tried?

I tried to run this from RAD, but no corresponding class found to run.

@Christopher, I got both these methods mentioned there, but these must be associated with some Class and so why they are not found in the java 6 API spec?
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Murtuza Arzai wrote:
@Christopher, I got both these methods mentioned there, but these must be associated with some Class and so why they are not found in the java 6 API spec?

These are implicitly declared static methods.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

I tried to run this from RAD, but no corresponding class found to run.

How do you declare an enum as a class ?
Harsh Pensi
Ranch Hand

Joined: Aug 05, 2009
Posts: 67
Christophe Verré wrote:
How do you declare an enum as a class ?


Enums are compiled to a .class file.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Where are these methods documented
 
Similar Threads
where does enum.values() come from?
Enums and operators
Variables[code]
Enums in Treeset