Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

enum.valueOf(String name) missing from Javadoc 1.5 and 1.6

Tags:

This is probably a stupid question, but I'm using the method enum.valueOf(String name). No problem there, except that when I was checking the javadoc to find out more about this method, I couldn't find it. There is javadoc for valueOf(Class<T> enumType, String name) but none for enum.valueOf(String name) (which would suggest that a method with this signature doesn't exist - but clearly it does).

Am I missing something here, or is this an oversight in the javadoc for the API?

Thanks

like image 247
Kimberley Coburn Avatar asked Mar 21 '12 11:03

Kimberley Coburn


1 Answers

There is no method Enum.valueOf(String) However, every enum has a values() and valueOf(String) method generated by the compiler and these are documented. They are static methods and thus cannot be overridden or defined in a super class or interface.

Enum e = Enum.valueOf(""); // this doesn't compile 

http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Thread.State.html#values%28%29

http://docs.oracle.com/javase/6/docs/api/java/lang/Thread.State.html#values%28%29

Its the same in Java 5.0, 6 or 7.

For Java 5.0 http://docs.oracle.com/javase/specs/jls/se5.0/html/classes.html#8.9 (archive.org copy) (search for values) For Java 7 http://docs.oracle.com/javase/specs/jls/se7/html/jls-8.html#jls-8.9.2 provided by @kapep

like image 63
Peter Lawrey Avatar answered Sep 28 '22 22:09

Peter Lawrey