title: ArrayList containing different objects of the same superclass - how to access method of a subclass
body: <p><em>Hi I'm wondering if there is a simple solution to my problem,</em> </p>
  
  <p>I have an <code>ArrayList</code>:</p>
  
  <pre><code>ArrayList &lt;Animal&gt; animalList = new ArrayList&lt;Animal&gt;(); 
  
  /* I add some objects from subclasses of Animal */
  
  animalList.add(new Reptile());
  animalList.add(new Bird());
  animalList.add(new Amphibian());
  </code></pre>
  
  <p>They all implement a method <code>move()</code> - The <code>Bird</code> flies when <code>move()</code> is called. 
  I know I can access common methods and properties of the super class by using this</p>
  
  <pre><code>public void feed(Integer animalIndex) {
      Animal aAnimal = (Animal) this.animalList.get(animalIndex);
      aAnimal.eat();
  }
  </code></pre>
  
  <p>That's fine - but now I would like to access the <code>move()</code> method the subclass <code>Bird</code> has.
  I could do this by casting the <code>Animal</code> as a <code>Bird</code>:</p>
  
  <pre><code>Bird aBird = (Bird) this.animalList.get(animalIndex);
  aBird.move();
  </code></pre>
  
  <p>In my situation I don't want to do this, as it will mean I have 3 different sets of the above code one for each subtype of <code>Animal</code>.</p>
  
  <p>It seems a bit redundant, is there a better way?</p>