title: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0 at xxx while calculating an average of integer numbers
body: <p>Simple average program I am trying to make but</p>
  
  <pre><code>Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0  at average.main(average.java:8)
  </code></pre>
  
  <p>The eighth line (the rest is below) is</p>
  
  <pre><code>int i1 = Integer.parseInt(args[i]);
  </code></pre>
  
  <p>Full code below:</p>
  
  <pre><code>public class average {
  
      public static void main (String args[]) {
  
          int sum = 0;
  
          for(int i = 0; i &lt;= args.length; i++) {
                  int i1 = Integer.parseInt(args[i]);
                  sum = i1 + sum;
          }
  
          int average = sum / (args.length - 1);
          System.out.println(average);
      }
  }
  </code></pre>