title: Does the Enum#values() allocate memory on each call?
body: <p>I need to convert an ordinal <code>int</code> value to an enum value in Java. Which is simple:</p>
  
  <pre><code>MyEnumType value = MyEnumType.values()[ordinal];
  </code></pre>
  
  <p>The <code>values()</code> method is implicit, and I cannot locate the source code for it, hence the question.</p>
  
  <p>Does the <code>MyEnumType.values()</code> allocate a new array or not? And if it does, should I cache the array when first called? Suppose that the conversion will be called quite often.</p>