title: Can't understand array error
body: <p>I just read the intro to arrays section in my AP Java book and tried the following example however I get an error and cant understand why.</p>
  
  <p>Code: </p>
  
  <pre><code>public static void arrayT(int i){
    String[] alphabet = new String[5];
    alphabet[0] = "a";
    alphabet[1] = "c";
    alphabet[2] = "x";
    alphabet[3] = "b";
    alphabet[4] = "d";
    alphabet[5] = "e";
    System.out.println(alphabet[i]);
  }
  </code></pre>
  
  <p>Main: </p>
  
  <pre><code>public static void main(String [] args){
    arrayT(2);
  }
  </code></pre>
  
  <p>Output: </p>
  
  <pre><code>Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 5
  at Main.arrayT(Main.java:18)
  at Main.main(Main.java:36)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:606)
  at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
  </code></pre>
  
  <p>What am I doing wrong?</p>