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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With