title: What is better to iterate over an EnumMap in java?
body: <p>Suppose I have declared an enum and corresponding emummap as:</p>
  
  <pre><code>enum MyEnum {
      CONSTANT1, CONSTANT2, CONSTANT3;
  }
  
  EnumMap&lt;MyEnum, String&gt; MyEnumMap = new EnumMap&lt;MyEnum, String&gt;(MyEnum.class);
  </code></pre>
  
  <p>I want to iterate over <code>MyEnumMap</code>, for example, just to print each <code>Entry</code> one by one.</p>
  
  <p>What is the best approach(fastest) to iterate over keys in the following cases:</p>
  
  <ol>
  <li>When it is ensured that each constant in <code>MyEnum</code> is a key in <code>MyEnumMap</code></li>
  <li>When each constant in <code>MyEnum</code> may or may not be a key in <code>MyEnumMap</code></li>
  </ol>
  
  <p>I want to choose between foreach loop using <code>MyEnumMap.keySet()</code> or <code>MyEnum.values()</code>. Any other approach is most welcomed.</p>