title: Any optimized technique to set array values in bean?
body: <p>I'm getting an array with fixed size of let's say 20.  </p>
  
  <p>I have to set each array element in a bean property, so my bean has 20 properties.</p>
  
  <p>Here's my current approach: </p>
  
  <pre><code>Object[] record = { "0", "1", "2", ...."19" };
  
  for (int j = 0; j &lt; record.length; j++) {
      if (j == 0) {
          bean.setNo((String) record[j]);
      }
      if (j == 1) {
          bean.setName((String) record[j]);  
      }
      if (j == 2) {
          bean.setPhone((String) record[j]);  
      }
      // so on and so forth...
  }
  </code></pre>
  
  <p>This is how i'm setting every property of bean from array.  </p>
  
  <p>Here i have 20 elements in array.  </p>
  
  <p>So to set 20th element it is checking 20 conditions.. Performance issue..   </p>
  
  <p>Any optimized technique is appreciated... </p>
  
  <p>Thanks in advance...</p>