title: Using methods from a subclass on an object that is an instance of the superclass
body: <p>Let's say there's a class that I use extensively and is returned by a method.</p>
  
  <pre><code>CommonClass obj = getCommonObject();
  </code></pre>
  
  <p>Now I want to extend this class to create some utility method to avoid repeating myself.</p>
  
  <pre><code>public CommonClassPlus extends CommonClass {
  
      public String dontRepeatYourself() {
          // the reason I'm creating a subclass
      }
  }
  </code></pre>
  
  <p>Of course I would like to use my improved class for the method above, however, downcasting isn't allowed.</p>
  
  <pre><code>CommonClassPlus obj = getCommonObject(); 
  //Cannot cast to CommonClassPlus
  </code></pre>
  
  <p>How can I use the method <code>dontRepeatYourself()</code> if I can only work with the object that is an instance of the superclass?</p>
  
  <p><code>CommonClass</code> and <code>getCommonObject()</code> are from an external library and I cannot change them.</p>