title: Setting a value into a object using reflection
body: <p>I have an object that has a <strong>lot of attributes</strong>, each one with it's getter and setter. Each attribute has a non primitive type, that I don't know at runtime.</p>
  
  <p>For example, what I have is this:</p>
  
  <pre><code>public class a{
  
      private typeA attr1;
      private typeB attr2;
  
      public typeA getAttr1(){ return attr1; }
      public typeB getAttr2(){ return attr2; }
  
      public void setAttr1(typeA at){ attr1 = at; }
      public void setAttr2(typeB at){ attr2 = at; }
  }
  
  public class typeA{
      public typeA(){
          // doesn't matter
      }
  }
  
  public class typeB{
      public typeB(){
          // doesn't matter
      }
  }
  </code></pre>
  
  <p>So, using reflection, I obtained the setter method for an attribute. Setting a value in the standard way is something like this:</p>
  
  <pre><code>a test = new a();
  a.setAttr1(new typeA());
  </code></pre>
  
  <p>But how can I do this using reflection? I already got the <strong>setAttr1()</strong> method using reflection, but I don't know how to create a new <strong>typeA</strong> object to be inserted in the setter.</p>