Why doesn't java compiler tell 'cannot cast error' for this casting?
<p>I just got confused with one java compilation scenario  which behaves odd with the given problem.</p>

<p>The below code will give compilation error (cannot cast types),because A and B are distinct classes and they have no relation between them.</p>

<pre><code>        A a = new A();
        B b = new B();

        B b1 = (B)a;
        A a1 = (A)b;
</code></pre>

<p>In the same way, If I cast the List and Map to each other ,it should give me compilation error.But its not giving any such error,ofcourse i am getting ClassCastException at runtime.</p>

<pre><code>        List&lt;String&gt; listObj = new ArrayList&lt;String&gt;();
        Map&lt;Integer,Float&gt; mapObj = new HashMap&lt;Integer,Float&gt;();

        Map newMapObj = (Map) listObj;
        List newListObj = (List) mapObj;
</code></pre>

<p>What could be the reason for this adjustment...</p>
