title: How to iterate over this generic List with wildcards?
body: <p>I have a List of objects that extend another class:</p>
  
  <pre><code>List&lt;? extends Fruit&gt; arguments;
  </code></pre>
  
  <p>Now, I want to invoke a method on these objects. The invoking class has a method <code>wash</code> for each of the classes that extend <code>Fruit</code>, but NOT for the <code>Fruit</code> abstract class:</p>
  
  <pre><code>void wash( Apple a);
  void wash( Peach p);
  </code></pre>
  
  <p>How can I apply the method wash to all the elements in <code>arguments</code>? This DOESN'T work, as my wash methods don't accept <code>Fruit</code> arguments:</p>
  
  <pre><code>for( Fruit f: arguments)
      this.wash( f); // the wash() method is not a member of Fruit
  </code></pre>
  
  <p>Is there any way to solve this without having to make an umbrella method <code>wash( Fruit)</code>? Because there are dozens of <code>wash( ? extends Fruit)</code> methods...</p>
  
  <p>.</p>
  
  <p><strong>EDIT</strong>: The "invoking class" I am talking about is a visitor. And I can't alter any of the <code>Fruit</code> classes/subclasses. I can only program the visitor. This means it isn't possible to add the <code>wash()</code> method (or any other methods, for that matter) to the abstract class <code>Fruit</code>.</p>