Java Typecasting & Calling Methods Simultaneously
<p>Very new to Java.</p>

<p>I have a class called <code>GraphicsObject</code> and a class <code>Bug</code> that extends it.</p>

<p>I have an ArrayList that holds all GraphicsObject in it:</p>

<pre><code>private ArrayList&lt;GraphicsObject&gt; gc = new ArrayList();
</code></pre>

<p>Then I have a function that gets called every frame called updateObjects().</p>

<pre><code>public void updateObjects(){
        for(int i = 0; i &lt; gc.size(); i++){
            if(gc.get(i).toString().equals("Bug") ){
                (Bug)gc.get(i).moveNorth();
            }
        }
    }
</code></pre>

<p>The typecasting fails and the moveNorth() method never gets recognized because the class GraphicsObject does not have that method, only Bug does.</p>

<p>Any solutions?</p>
