title: Static (and final) field initialization in an enum in Java
body: <p>Say I have this enumerated type of Colours as follows:</p>
  
  <pre><code>public enum Colour
  {
      RED, GREEN, BLUE;
  }
  </code></pre>
  
  <p>I want to randomize a colour out of those three, following the suggestion found over there: <a href="https://stackoverflow.com/a/8114214/2736228">https://stackoverflow.com/a/8114214/2736228</a></p>
  
  <p>But I don't want to make a call to <code>values()</code> over and over again, so, I came up with something as follows:</p>
  
  <pre><code>public enum Colour
  {
      RED, GREEN, BLUE;
  
      private static final Colour[] Values = values();
  
      public static Colour random()
      {
          return Values[(int) (Math.random() * Values.length)];
      }
  }
  </code></pre>
  
  <p>Question is, will it work, always?</p>
  
  <p>What confuses me here, is that when the initialization of this <code>private static final</code> field occurs. It should be happening after the full list of enumeration is completed. I don't see it happening anytime soon, but still, I want to make sure.</p>