title: Java run time class reflection
body: <p>Say if I have a class named Car I can use the following line of code in certain situations.</p>
  
  <p><code>Car.class</code></p>
  
  <p>My question is there a way I can make the same type of call if a user supplies a class name at run time. Have tried something similar to the below but no joy, is there a way i can do it. </p>
  
  <pre><code>String className = "Car";
  Class.forName(className ).class;
  </code></pre>
  
  <p>Also I need to be able to cast dynamically, if the user specifies a list of objects I need to be able to dynamically cast.</p>
  
  <p>e.g. instead of <code>Car myCar = (Car) object</code></p>
  
  <p>I need to be able to have to the user specify the name/type of class at run time so that I need to be able to do something along the lines of <code>ClassName myObj = (ClassName) object</code>.</p>