title: Cast Int to enum in Java
body: <p>What is the correct way to cast an Int to an enum in Java given the following enum?</p>
  
  <pre><code>public enum MyEnum
  {
      EnumValue1,
      EnumValue2
  }
  
  
  MyEnum enumValue = (MyEnum) x; //Doesn't work???
  </code></pre>