title: cast back from supertype to child
body: <p>Let's say I have a super type (Shape) and two children (like Square, Circle).</p>
  
  <p>I'm trying to make something like this:</p>
  
  <pre><code>Shape shape = someObject.getShape();
  
  if (shape instanceof Square){
      shape = (Square) shape;
      // do this
  } else if (shape instanceof Circle) {
      shape = (Circle) shape;
      // do that
  }
  </code></pre>
  
  <p>Also, since getting instances doesn't seem a correct OO principle, is there another way doing that? Cheers.</p>
  
  <p><strong>edit.</strong> I'm not trying to invoke methods on them, I want to pass them to some methods that need their specific subtype.</p>
  
  <p><strong>edit2</strong> Basically I have a collection of type Shape so I can hold both type of subtypes in it. But when it comes to processing at one point, I need to know which of those two subclasses is, so I can pass it to a method that takes the subtype as an argument. I could easily use the supertype as argument but that wouldn't be secure, since I deal with subtype-specific data.</p>