title: Help with Java Generics: Cannot use "Object" as argument for "? extends Object"
body: <p>I have the following code:</p>
  
  <pre><code>import java.util.*;
  
  public class SellTransaction extends Transaction {
      private Map&lt;String,? extends Object&gt; origValueMap;
      public SellTransaction(Map&lt;String,? extends Object&gt; valueMap) {
          super(Transaction.Type.Sell);
          assignValues(valueMap);
          this.origValueMap=valueMap;
      }
      public SellTransaction[] splitTransaction(double splitAtQuantity) {
          Map&lt;String,? extends Object&gt; valueMapPart1=origValueMap;
          valueMapPart1.put(nameMappings[3],(Object)new Double(splitAtQuantity));
          Map&lt;String,? extends Object&gt; valueMapPart2=origValueMap;
          valueMapPart2.put(nameMappings[3],((Double)origValueMap.get(nameMappings[3]))-splitAtQuantity);
          return new SellTransaction[] {new SellTransaction(valueMapPart1),new SellTransaction(valueMapPart2)};
      }
  }
  </code></pre>
  
  <p>The code fails to compile when I call <code>valueMapPart1.put</code> and <code>valueMapPart2.put</code>, with the error:</p>
  
  <pre>The method put(String, capture#5-of ? extends Object) in the type Map is not applicable for the arguments (String, Object)</pre>
  
  <p>I have read on the Internet about generics and wildcards and captures, but I still don't understand what is going wrong. My understanding is that the value of the <code>Map</code>'s can be any class that extends Object, which I think might be redundant, because all classes extend Object. And I cannot change the generics to something like <code>? super Object</code>, because the <code>Map</code> is supplied by some library.</p>
  
  <p>So why is this not compiling? Also, if I try to cast <code>valueMap</code> to <code>Map&lt;String,Object&gt;</code>, the compiler gives me that 'Unchecked conversion' warning.</p>
  
  <p>Thanks!</p>