title: wildcard, generic, setter and getter in java
body: <p>I've got a generic class with subclass.</p>
  
  <pre><code>public class GenericClass&lt;C&gt;
  {
      private C value;
  
      public C getValue() { return value; }
  
      public void setValue(C value) { this.value = value; }
  }
  </code></pre>
  
  <p>In my code I use subclasses without knowing what subclasses but I know this two subclasses are same type :</p>
  
  <pre><code>GenericClass&lt;?&gt; obj1 = ... // has a value here
  GenericClass&lt;?&gt; obj2 = ... // has a value here
  
  // I know that obj1 is the same type of obj2 but I don't know this type.
  obj1.setValue(obj2.getValue());
  </code></pre>
  
  <p>The last line produce a compilation error which is : </p>
  
  <blockquote>
    <p>The method setValue(capture#11-of ?) in the type GenericClass is
    not applicable for the arguments (capture#12-of ?)</p>
  </blockquote>
  
  <p>How can I do that (something like casting a wildcard...) ?</p>