Results 1 to 6 of 6
- 10-05-2011, 11:20 AM #1
Member
- Join Date
- Sep 2011
- Posts
- 4
- Rep Power
- 0
Java Eclipse error java.lang.ArrayIndexOutOfBoundsException
Hi frndz my code is
public class ADD
{
public static void main(String[] args)
{
int a,b;
a=Integer.parseInt(args[0]);
b=Integer.parseInt(args[1]);
System.out.println("sum is "+(a+b));
}
}
when I used it from cmd it works fine
output:-
c:\>java ADD 5 9
sum is 14
I am new on Java Eclipse but same code when I used in Java Eclipse IDE it gives me Error:-
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at ADD.main(ADD.java:7)
Plz Help Thnx....
- 10-05-2011, 12:24 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 14,422
- Blog Entries
- 7
- Rep Power
- 29
Re: Java Eclipse error java.lang.ArrayIndexOutOfBoundsException
Did you pass your command line arguments? My guess is that you didn't ... it isn't Eclipse's fault.
kind regards,
JosBuild a wall around Donald Trump; I'll pay for it.
- 10-05-2011, 02:19 PM #3
Member
- Join Date
- Sep 2011
- Posts
- 4
- Rep Power
- 0
Re: Java Eclipse error java.lang.ArrayIndexOutOfBoundsException
hey I got it....
I found Arguments tab in Run config...
THNX...
- 07-25-2012, 04:01 PM #4
Member
- Join Date
- Jul 2012
- Posts
- 2
- Rep Power
- 0
Re: Java Eclipse error java.lang.ArrayIndexOutOfBoundsException
Dis s d correct one..try this..
public static void main(String[] args) throws IOException {
System.out.println("Addition of two numbers!");
BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
String s=buf.readLine();
int a=Integer.parseInt(s);
String t=buf.readLine();
int b=Integer.parseInt(t);
int sum = a + b;
System.out.println("Sum: " + sum);
}
}
- 07-25-2012, 04:02 PM #5
Member
- Join Date
- Jul 2012
- Posts
- 2
- Rep Power
- 0
Re: Java Eclipse error java.lang.ArrayIndexOutOfBoundsException
how u got ..could u pls explain ???
- 07-25-2012, 05:11 PM #6
Re: Java Eclipse error java.lang.ArrayIndexOutOfBoundsException
Forum Rules
http://www.java-forums.org/forum-gui...w-members.html
BB Code List - Java Programming Forum
Also, don't spoonfeed code and don't post to long dead threads. The question was asked more than a year ago.
db
THREAD CLOSEDIf you're forever cleaning cobwebs, it's time to get rid of the spiders.
Similar Threads
-
Need help with error: java.lang.ArrayIndexOutOfBoundsException: 1
By iowndd in forum New To JavaReplies: 4Last Post: 10-02-2011, 09:29 PM -
java.lang.ArrayIndexOutOfBoundsException error
By MBD in forum New To JavaReplies: 1Last Post: 09-27-2011, 07:47 PM -
Runtime error "Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
By shantimudigonda in forum New To JavaReplies: 1Last Post: 11-20-2009, 08:58 PM -
Error: java.lang.ArrayIndexOutOfBoundsException
By fernando in forum Java 2DReplies: 1Last Post: 08-01-2007, 12:47 AM -
Error: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException
By romina in forum New To JavaReplies: 1Last Post: 07-25-2007, 11:55 PM
Bookmarks