title: Tricky Java Generics : generic class implementing non generic interface with generic Method
body: <p>I have the following code <a href="http://ideone.com/4om8jH" rel="nofollow">as seen in ideone.com</a>:</p>
  
  <pre><code>import java.util.*;
  
  class Test{
     interface Visitor{
          public &lt;T&gt; void visit(T Value);
     }
  
     class MyVisitor&lt;T&gt; implements Visitor{
          List&lt;T&gt; list = new  ArrayList&lt;T&gt;();
  
          public &lt;T&gt; void visit(T value){
             list.add(value);
          }
      }
  }
  </code></pre>
  
  <p>When compiled this code will produce the following+ error:</p>
  
  <pre>
   Main.java:12: error: no suitable method found for add(T#1)
               list.add(value);
                   ^
       method List.add(int,T#2) is not applicable
         (actual and formal argument lists differ in length)
       method List.add(T#2) is not applicable
         (actual argument T#1 cannot be converted to T#2 by method invocation conversion)   where T#1,T#2 are type-variables:
       T#1 extends Object declared in method visit(T#1)
       T#2 extends Object declared in class Test.MyVisitor 1 error
  </pre>
  
  <p>The problem is that the <b>type T in visit</b> is not considered the same <b> T in list </b>. How can I fix this compilation problem?</p>