title: How to create object for a class dynamically in java
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1268817/create-new-class-from-a-variable-in-java">Create new class from a Variable in Java</a>  </p>
  </blockquote>
  
  
  
  <p>i had a scenario like this,</p>
  
  <pre><code> String className;
  
   if(someCondition){
  
   className="A";
  
     }
   else{
     className='B'
    }
  </code></pre>
  
  <p>Now i want to do this dynamically</p>
  
  <pre><code> className obj=(className) dbObj;//i am typcasting the db casting to particular class
  </code></pre>
  
  <p>Note:Here A and B classes having same setters and getters but belongs to two different tables in db</p>