title: Java cast parent to child?
body: <p>Here is my code:</p>
  
  <pre><code>for (DrawableEntity entity : drawableEntityList) {
      if (entity instanceof Beam) {
          (Beam) entity.age += timeElapsed;
      }
      else if (entity instanceof Block) {
  
      }
  }
  </code></pre>
  
  <p>Basically <code>drawableEntityList</code> is a <code>Vector</code> of <code>DrawableEntitys</code>, and I want to iterate through everything in the <code>Vector</code>. Then depending on if they are subclass <code>Beam</code> or subclass <code>Block</code> I want to do something different.</p>
  
  <p>The problem is that I'm trying to change a variable that only the subclasses have, I figured I could cast with (Beam) but it doesn't work.</p>
  
  <p>Is it not possible to cast a parent class to a child class?</p>