2

Reading the official API documentation about Enum, you have to go to the description of method valueOf(Class<T> enumType, String name) and read:

Note that for a particular enum type T, the implicitly declared public static T valueOf(String) method on that enum may be used instead of this method to map from a name to the corresponding enum constant. All the constants of an enum type can be obtained by calling the implicit public static T[] values() method of that typevalue.

Ok, values() and valueOf(name) are not methods of Enum class, but for what Eclipse tells me, the only attributes and methods of Enum are class, super, this and valueOf(Class<T> enumType, String name). So also the other documented methods are specific to the enum type. Knowing that, why not documenting also values() and valueOf(name) separately? If I didn't read about valueOf() and values() on SO, I never know about them.

Michael
  • 41,989
  • 11
  • 82
  • 128
Marco Sulla
  • 15,299
  • 14
  • 65
  • 100
  • 4
    It's just one of those weird exceptions that doesn't really fit anywhere. The method is generated by the compiler. "why not documenting also `values()` and `valueOf(name)` separately". The point is that there is nowhere to properly document them. – Michael May 01 '19 at 14:11
  • So it's a problem of javadoc? – Marco Sulla May 01 '19 at 14:14
  • 1
    No, [JavaDoc will add them](https://docs.oracle.com/javase/8/docs/api/java/time/DayOfWeek.html#valueOf-java.lang.String-), you just have to look at the enum itself rather than any kind of super class. – Michael May 01 '19 at 14:16
  • Just to note, the class documentation of `Enum` states: "_More information about enums, including descriptions of the implicitly declared methods synthesized by the compiler, can be found in section 8.9 of The Java™ Language Specification_". While it doesn't tell you about the methods themselves, it does indicate the presence of implicit methods added by the compiler and gives the corresponding section of the JLS that describes them. However, I'd agree with the idea such documentation would be better located in the class' Javadoc rather than a method's Javadoc. – Slaw May 01 '19 at 14:47

0 Answers0