title: Improving Conversion of Array for Reflection Invocation
body: <p>I have three arrays (in the same size):</p>
  
  <ol>
  <li><code>JSONArray jsonArr</code> which contains many strings.</li>
  <li><code>Class&lt;?&gt; classArr[]</code> which contains the parameter types.</li>
  <li><code>Object objArr[]</code> which contains nothing yet (but we'll make it full, I promise)</li>
  </ol>
  
  <p>I need to convert each of the Strings in <strong>jsonArr</strong> to the type from the same index in <strong>classArr</strong> and put the resulted object in the appropriate index in <strong>objArr</strong>.</p>
  
  <p>For example:</p>
  
  <pre><code>Array \ index |  1      |   2     |   3     |  4
  --------------+---------+---------+---------+-------
  jsonArr       | "1"     | "false" | "false" | "2"
  classArr      | int     | boolean | String  | char
  </code></pre>
  
  <p>Should result in: </p>
  
  <pre><code>objArr        | 1       | false   | "false" | 2
  </code></pre>
  
  <p>I currently use the following method (in a loop for every object) to convert the parameters and create <code>objArray</code>:</p>
  
  <pre><code>if (classArr[i].equals(int.class))
      objArr[i] = Integer.parseInt(jsonArr.get(i));
  else if (classArr[i].equals(boolean.class))
      objArr[i] = Boolean.parseBoolean(jsonArr.get(i));
  ....
  </code></pre>
  
  <p>This method works just fine for me, but I wonder - <strong>is there a better way to convert the JSONArray to the types I have in list, or I have no better option than the <code>if-else</code> approach?</strong></p>