title: Java: enum values() and valueOf(String)
body: <p>Why does javac add <code>values()</code> and <code>valueOf(String)</code> methods to the enum type being defined? Wouldn't it have been better that they were added to Enum class itself?</p>
  
  <p>What I mean is, if I have some enum such as</p>
  
  <pre><code>enum FooEnum {ONE, TWO}
  </code></pre>
  
  <p>javac adds <code>values()</code> and <code>valueOf(String)</code> to <code>FooEnum</code> when compiling it. I find it a bit odd. What is the reason behind this? </p>
  
  <p><em>Is it only to ensure type safety of the returned value/values or is there anything else? And  if it's for type safety alone, wouldn't Generics have helped?</em></p>