title: Casting to Unknown Type When Class Name as a String
body: <pre><code>public class ExampleClass {
      public static void main(String[] args) {
          // TODO Auto-generated method stub
          Horse hr1 = new Horse();
          Horse hr2 = new Horse();
          Horse hr3 = new Horse();
          Horse hr4 = new Horse();
          Set hrSet = new HashSet();
          hrSet.add(hr1);
          hrSet.add(hr2);
          hrSet.add(hr3);
          hrSet.add(hr4);
          Horse hr;
          String hor = "sher_pkg.Horse";
          callHorse(hrSet,hor);
      }
      public static void callHorse(Set xSet,String clsName){
          try {
              Class hrt = Class.forName(clsName);
  
              Iterator hritr = xSet.iterator();
              while(hritr.hasNext()){
                  exam(hrt.cast(hritr.next()));
              }
          } catch (ClassNotFoundException e) {
              e.printStackTrace();
          }
      }
      public static void exam(Object obj){ //I want to use exam(Horse hrr)
          System.out.println(obj);
      }
  }
  </code></pre>
  
  <p>Here the argument for the exam function is an <code>Object</code>. But I want to have the argument be <code>Horse</code>... so what changes must be done in "<code>exam(hrt.cast(hritr.next()))</code>" method call? I don't want to explicitly use the class name <code>Horse</code> in <code>callHorse()</code>... So what am I supposed to do?</p>
  
  <p>Thanks</p>