title: Getting an ArrayIndexOutOfBoundsException
body: <p>I have this code :     </p>
  
  <pre><code>public class OddSum1 {
     public OddSum1() {
     }
     public static void main(String[] args) {
  
     int OddLimit = Integer.parseInt(args[0]);
     int sum = 0;
  
     for (int i = 1; i &lt;= OddLimit; i += 2) {
       sum += i;
     }
  
     System.out.println("The sum of odd numbers from 1 to " + OddLimit + " is " + sum);
  
     }    
  }
  </code></pre>
  
  <p>Whenever I run it I get this error:</p>
  
  <pre><code>java.lang.ArrayIndexOutOfBoundsException: 0
      at OddSum1.main(OddSum1.java:7)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at edu.rice.cs.drjava.model.compiler.JavacCompiler.runCommand(JavacCompiler.java:272)
  </code></pre>
  
  <p>It's supposed to prompt user for a number and then sums the odd number from 1 to the number entered, I'm guessing it's a problem with this <code>int OddLimit = Integer.parseInt(args[0])</code>;</p>
  
  <p>but I just don't know how to fix it, any help would be awesome.</p>