title: How to use fields in java enum by overriding the method?
body: <p>The task is to implement beautiful strategy design pattern with the java <code>enum</code>:</p>
  
  <pre class="lang-java prettyprint-override"><code>public enum MyEnum {
  
      FIRST {
          @Override
          public String doIt() {
              return "1: " + someField; //error
          }
      },
      SECOND {
          @Override
          public String doIt() {
              return "2: " + someField; //error
          }
      };
  
      private String someField;
  
      public abstract String doIt();
  
  } 
  </code></pre>
  
  <p>but when referring to <code>someField</code> I get</p>
  
  <blockquote>
    <p>Cannot make a static reference to the non-static field someField.</p>
  </blockquote>
  
  <p>What is wrong and is it possible to do that better?</p>