title: Strange behavior when using Enum as type in Map
body: <p>When I am using an Enum as a type in Map, I am not getting a compile time error if I use a key whose type is different. For example in the code snippet below, I expected a compile time error when I tried accessing the map with a key whose type is String.</p>
  
  <p>Why does generic not provide compile time safety when using generics in Map? 
  When I try to insert an entry compile time check works.</p>
  
  <p>With List this does not seem to be the case as I get a compile time error.</p>
  
  <p>Consider the code sample below</p>
  
  <pre><code>import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.List;
  import java.util.Map;
  
  
  public class TestEnumGeneric{
  
      enum Sample{
              A,B
          }
      enum Sample2 {
            C,D
          }
      Map&lt;Sample,String&gt; someMap = new HashMap&lt;Sample, String&gt;();
      Map&lt;String,String&gt; someOtherMap = new HashMap&lt;String, String&gt;();
      List&lt;Sample&gt; someList = new ArrayList&lt;Sample&gt;();
  
      public void testMapWithEnum() {
          String value = someMap.get("123");
          value = someMap.get(Sample2.C);
          String value2 = someOtherMap.get(1);
          //someMap.put("123","123");
          //someList.add("123");
      }
  }
  </code></pre>