title: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 5
body: <pre><code>public class dereks {
  public static void main (String [] args){
      int array [] = {1,2,3,5,6,7};
      int sum =0;
      for(int counter=0; counter&lt;=array.length; counter++){
          sum+=array[counter];
      }
      System.out.println(sum);
  }
  }
  </code></pre>
  
  <p>Can anyone tell me whats wrong with this?? I can't understand why I'm getting the error message "Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 5
  at dereks.main(dereks.java:7)" .  </p>