title: Java generics in inheritence
body: <p>I am having some (philosophical?) problems with java's generics...</p>
  
  <p>Consider the following</p>
  
  <pre><code>public interface ClassA&lt;I&gt; {}
  
  public class Obj implements ClassA&lt;String&gt; {}    
  
  public interface ClassB&lt;I, T extends ClassA&lt;I&gt;&gt; {
      public I getSomething();
      public T getAnotherThing();
  }
  </code></pre>
  
  <p>This compiles and works ok, if an object of ClassB  is instantiated as:</p>
  
  <pre><code>ClassB&lt;String, Obj&lt;String&gt;&gt; o = new ClassB&lt;&gt;();
  o.getSomething(); // &lt;-- Returns String
  </code></pre>
  
  <p>I was wondering if there is a way to avoid instantiating a ClassB object without having to specify the String generic as well, since it's already inside ClassA. More specifically, I'd like to use it as:</p>
  
  <pre><code>public interface ClassB&lt;T extends ClassA&lt;I&gt;&gt; { // &lt;-- Won't compile
      public I getSomething(); 
  }
  ClassB&lt;Obj&gt; o = new ClassB&lt;&gt;(); 
  o.getSomething(); // &lt;-- Returns String from Obj declaration, which uses ClassA&lt;String&gt;
  </code></pre>
  
  <p>I know the "problem" can be easily gotten over with the first example, but I wanted to know if there's a way of reference the actual type of the generic in the implementing ClassA object without having to pass it again in ClassB's declaration, and if not, why.</p>
  
  <p>Hope I was clear enough with my dilemma. 
  Thanks</p>