title: Converting String to int array, java.lang.ArrayIndexOutOfBoundsException: 6
body: <p>Here is a little snippet of my code, which is attempting to convert a length 6 string into an int array.</p>
  
  <pre><code>int[] intArray=new int[6];
  int i = 0;
  String s = jTextField2.getText();
  int strLength = s.length();
  if(strLength != 6) {
    jTextArea1.setText("Not a valid length");
  } else {
    for(i=0;i&lt;6;i++) {
      intArray[i] = Integer.parseInt(String.valueOf(s.charAt(i)));
    }
  }
  </code></pre>
  
  <p>This comes up with an out of bounds exception and I cant understand why.</p>
  
  <p>Thanks for any help.</p>