why HashMap Values are not cast in List?
<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 values 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>it throw exception:</p>

<blockquote>
  <p>Exception in thread "main" java.lang.ClassCastException:
  java.util.HashMap$Values cannot be cast to java.util.List</p>
</blockquote>

<p>But it allow to create list in definition of list like:</p>

<pre><code>List&lt;Double&gt; valuesToMatch  = new ArrayList&lt;Double&gt;( highLowValueMap.values());
</code></pre>
