title: java.lang.ArrayIndexOutOfBoundsException: length=6; index=6 | String.xml
body: <p>in my little app I want to display something from my String.xml
  I normaly use this to do this:</p>
  
  <pre><code>public void putText() {
      String[] text1 = getResources().getStringArray(R.array.text1);
      String[] text2 = getResources().getStringArray(R.array.text2);
  
  
      if(selecter &gt;= MAX) {
          selecter = 0;
      }
      else {
          selecter++;
      }
  
      // Texte anzeigen und Shown table auf true setzen.
      // normally selecter instead of 6
      txt_text1.setText(text1[6]);
      txt_text2.setText(text2[6]);
  }
  </code></pre>
  
  <p>but when 'selecter' is between 6 and 9(nine is the MAX variable) the app crashes with this error:</p>
  
  <pre><code>FATAL EXCEPTION: main
                                                     Process: com.example.alex.wouldyoupressthebutton, PID: 22844
                                                     java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.alex.wouldyoupressthebutton/com.example.alex.wouldyoupressthebutton.MainActivity}: java.lang.ArrayIndexOutOfBoundsException: length=6; index=6
                                                         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2750)
                                                         at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2811)
                                                         at android.app.ActivityThread.-wrap12(ActivityThread.java)
                                                         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1528)
                                                         at android.os.Handler.dispatchMessage(Handler.java:102)
                                                         at android.os.Looper.loop(Looper.java:154)
                                                         at android.app.ActivityThread.main(ActivityThread.java:6316)
                                                         at java.lang.reflect.Method.invoke(Native Method)
                                                         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872)
                                                         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762)
                                                      Caused by: java.lang.ArrayIndexOutOfBoundsException: length=6; index=6
                                                         at com.example.alex.wouldyoupressthebutton.MainActivity.putText(MainActivity.java:175)
                                                         at com.example.alex.wouldyoupressthebutton.MainActivity.onCreate(MainActivity.java:85)
                                                         at android.app.Activity.performCreate(Activity.java:6757)
                                                         at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
                                                         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2703)
                                                         at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2811) 
                                                         at android.app.ActivityThread.-wrap12(ActivityThread.java) 
                                                         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1528) 
                                                         at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                         at android.os.Looper.loop(Looper.java:154) 
                                                         at android.app.ActivityThread.main(ActivityThread.java:6316) 
                                                         at java.lang.reflect.Method.invoke(Native Method) 
                                                         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872) 
                                                         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762) 
  </code></pre>
  
  <p>Here is also my string.xml</p>
  
  <pre><code>&lt;string-array name="text1"&gt;
      &lt;item&gt;You would have everything you want&lt;/item&gt;
      &lt;item&gt;You can go back in time when you want&lt;/item&gt;
      &lt;item&gt;You gain the ability to communicate with animals&lt;/item&gt;
      &lt;item&gt;You gain any one super-power of your choice (aside from immortality)&lt;/item&gt;
      &lt;item&gt;You would become the greatest player in your favorite sport&lt;/item&gt;
      &lt;item&gt;You gain omniscience (infinite knowledge of everything)&lt;/item&gt;
      &lt;item&gt;You become the most talented musician in the world (any instrument)&lt;/item&gt;
      &lt;item&gt;Instead of Dying, you regenerate&lt;/item&gt;
      &lt;item&gt;You wil have unlimited money&lt;/item&gt;
      &lt;item&gt;Everyone on earth love and adore you&lt;/item&gt;
  &lt;/string-array&gt;
  &lt;string-array name="text2"&gt;
      &lt;item&gt;you don\'t understand the human language anymore.&lt;/item&gt;
      &lt;item&gt;you can only talk to one person per each travel.&lt;/item&gt;
      &lt;item&gt;you lose the ability to communicate with humans&lt;/item&gt;
      &lt;item&gt;you lose your ability to swim&lt;/item&gt;
      &lt;item&gt;you would constantly be criticized&lt;/item&gt;
      &lt;item&gt;you have it for 24 hours, and afterwards you gain permanent down syndrome.&lt;/item&gt;
      &lt;item&gt;you cannot earn any money from your talent.&lt;/item&gt;
      &lt;item&gt;you only can regenerate 12 times, and each time you look like a different person but retain all memories.&lt;/item&gt;
      &lt;item&gt;you can never sleep again.&lt;/item&gt;
      &lt;item&gt;never fall in love yourself.&lt;/item&gt;
  &lt;/string-array&gt;
  </code></pre>
  
  <p>I have tried a shorter text in the String.xml but I still got the message... And this only happets between six and the MAX(9)</p>
  
  <p>any suggestions why?</p>