title: why HashMap Values are not cast in List?
body: <p>I'm putting values into the hashmap which is of the form,</p>
  
  <pre><code>Map&lt;Long, Double&gt; highLowValueMap=new HashMap&lt;Long, Double&gt;();
  highLowValueMap.put(1l, 10.0);
  highLowValueMap.put(2l, 20.0);
  </code></pre>
  
  <p>I want to create a list by using <code>values()</code> method of map.</p>
  
  <pre><code>List&lt;Double&gt; valuesToMatch=new ArrayList&lt;&gt;();
  valuesToMatch=(List&lt;Double&gt;) highLowValueMap.values();
  </code></pre>
  
  <p>or </p>
  
  <pre><code>List&lt;Double&gt; valuesToMatch=(List&lt;Double&gt;) highLowValueMap.values();
  </code></pre>
  
  <p>However, it throws an exception:</p>
  
  <blockquote>
    <p>Exception in thread "main" java.lang.ClassCastException:<br>
    java.util.HashMap$Values cannot be cast to java.util.List</p>
  </blockquote>
  
  <p>But it allows me to pass it in to the creation of a list:</p>
  
  <pre><code>List&lt;Double&gt; valuesToMatch  = new ArrayList&lt;Double&gt;( highLowValueMap.values());
  </code></pre>