title: How can I optimize this android code?
body: <p>I want to parse jsonarray which has uncertain length, </p>
  
  <ul>
  <li>if this array's length is 0,then children are null;</li>
  <li>if this array's length is 1,then children0 has some value,and others
  are null;</li>
  <li>if this array's length is 2,then children0 and children2 have some
  values, and children3 is null;</li>
  <li>if this array's length >= 3,then children0 and children1 and
  children2 have values.</li>
  </ul>
  
  <p>How can I optimize this code?</p>
  
  <p>That's all...</p>
  
  <p>It's my first time to ask question on stack overflow.</p>
  
  <p>I'm so sorry for my poor English...</p>
  
  <pre><code>String children0 = null;
  String children1 = null;
  String children2 = null;
  
  if (chArray.length() &gt; 2) {
      children0 = value0;
      children1 = value1;
      children2 = value2;
  } else if (chArray.length() == 2) {
      children0 = value0;
      children1 = value1;
  } else if (chArray.length() == 1) {
      children0 = value0;
  }
  </code></pre>