title: Java: Using Class.forName to dynamically get a new instance of itself
body: <p>Lets say I have a class named  Dog which is a subclass of Animal</p>
  
  <p>I have a method that needs to create an instance of a specific subclass of animal based on a string  parameter</p>
  
  <pre><code>public void createAnimalType(String animalType) {
  
  Class clazz = Class.forName(animalType);
  
  //Check if animalType  equals Dog, or Cat, or Fox, etc
  // Example
  Dog dog = (Dog) clazz.newInstance();
  ...
  </code></pre>
  
  <p>Is there a way to crate an instance of itself (Dog, Cat, etc, Not of type Animal) without using an explicit cast to the Subclass (Dog)in this case?</p>
  
  <p>I may be missing a finer point of polymorphism (as in why do I  want to do that . .  should be casting it to Object or Anmial :-) )</p>
  
  <p>Thanks for helping me get smart on this. </p>