Java : generic classes
<p>I read this code from my book:</p>

<pre><code>class B extends A {...}
class G&lt;E&gt; {
public E e;
}
G&lt;B&gt; gb = new G&lt;B&gt;();
G&lt;A&gt; ga = gb;
ga.e = new A();
B b = gb.e; // Error
</code></pre>

<p>Why <code>B b = gb.e;</code> arise an error? We didn't assign anything to b, and for that gb.e is from type B.</p>
