title: Extending Generic Classes
body: <pre><code>public class MyGeneric&lt;T, E&gt; {}
  
  public class Extend1&lt;T, E&gt; extends MyGeneric&lt;T, E&gt; {}
  
  public class Extend2 extends MyGeneric&lt;String, Object&gt; {}
  </code></pre>
  
  <p>As far as I am aware, both of the subclasses in the above example are valid. I was wondering how Java knows when the types given in the superclass are going to be defined when the subclass is instantiated, and when they are actual class names (i.e. How does it know T, E are not class names)?</p>
  
  <p>A side note, is it permissible (even if uncommon) to use more than one letter for the generic types? What if (through some sever error of planning) The types conflict with an existing class e.g.</p>
  
  <pre><code>public class E{}
  public class Foo&lt;E&gt;{}
  </code></pre>
  
  <p>what happens then?</p>
  
  <p>Edit: Thanks for answering so promptly.
  To answer my first question, <a href="https://stackoverflow.com/questions/7255643/java-extending-generic-classes/7255708#7255708">Joachim's answer</a> is most effective.</p>
  
  <p>To answer the side point, <a href="https://stackoverflow.com/questions/7255643/java-extending-generic-classes/7255672#7255672">aioobe's answer is clearer</a></p>