Exception in the thread main java.lang.ArrayIndexOutOfBounds : 0

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sindhu sunkara
    New Member
    • Feb 2012
    • 1

    Exception in the thread main java.lang.ArrayIndexOutOfBounds : 0

    the compilation will be done for every program but its not running the program. hello world is the only program that is giving the output. All the remaining programs are not getting executed. plz help me !!
    my sample example program is
    public class Sample
    {
    public static void main(String args[])
    {
    int a,b;
    a=Integer.parse Int(args[0]);
    b=Integer.parse Int(args[1]);
    System.out.prin tln("a= "+a);
    System.out.prin tln("b= "+b);
    }

    }
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    I'm pretty sure it's supposed to be String [] args and not what you have up there.

    Comment

    • neeraj0708
      New Member
      • Feb 2012
      • 21

      #3
      your code is perfect..

      but i think you are not giving input while running this program.

      after compiling "javac Sample.java" you have to run like this
      java Sample 10 20

      here 10 and 20 are the argument, that you must have to pass.
      otherwise you will get "Exception in the thread main java.lang.Array IndexOutOfBound s : 0" exception.

      Comment

      Working...