By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,650 Members | 1,388 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,650 IT Pros & Developers. It's quick & easy.

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

P: 1
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.parseInt(args[0]);
b=Integer.parseInt(args[1]);
System.out.println("a= "+a);
System.out.println("b= "+b);
}

}
Feb 8 '12 #1
Share this Question
Share on Google+
2 Replies


Rabbit
Expert Mod 10K+
P: 12,421
I'm pretty sure it's supposed to be String [] args and not what you have up there.
Feb 8 '12 #2

P: 21
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.ArrayIndexOutOfBounds : 0" exception.
Feb 9 '12 #3

Post your reply

Sign in to post your reply or Sign up for a free account.