title: How to call a subclass method from superclass?
body: <p>Java newbie here.</p>
  
  <p><code>Banana and Apple extend Fruit</code> (<code>Fruit</code> might as well be an abstract class since no Fruit will ever be instanciated).</p>
  
  <p><code>Banana</code> and <code>Apple</code> both have a (wildly different) <code>toString()</code> method.</p>
  
  <p>A method somewhere -- let's call it <code>processFruit(Fruit fruit)</code> -- accepts <code>Fruit</code> as a parameter, and then calls the <code>toString()</code> method of the actual <code>Fruit</code> received (meaning, either a banana or an apple), for logging purposes. How do I do this?</p>
  
  <p>I would like to do fruit.toString() and have it run the Apple.toString() or Banana.toString() method based on what the fruit actually is.</p>
  
  <p>Things I'd rather not do (because there are many fruits, not just apples and bananas):</p>
  
  <ol>
  <li>Have two distinct <code>processFruit</code> methods, <code>processFruit(Banana banana)</code> and <code>processFruit(Apple apple)</code>, because the code is identical</li>
  <li>Downcast the received fruit to either Apple or Banana, and then call its <code>toString()</code> method</li>
  </ol>
  
  <p>There must be another way but I can't see it.</p>