Results 1 to 6 of 6
  1. #1
    prathamkool is offline Member
    Join Date
    Sep 2011
    Posts
    4
    Rep Power
    0

    Default 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....

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,190
    Blog Entries
    7
    Rep Power
    24

    Default 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,

    Jos
    The only person who got everything done by Friday was Robinson Crusoe.

  3. #3
    prathamkool is offline Member
    Join Date
    Sep 2011
    Posts
    4
    Rep Power
    0

    Default Re: Java Eclipse error java.lang.ArrayIndexOutOfBoundsException

    hey I got it....
    I found Arguments tab in Run config...
    THNX...

  4. #4
    Nisha Raj is offline Member
    Join Date
    Jul 2012
    Posts
    2
    Rep Power
    0

    Default 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);
    }
    }

  5. #5
    Nisha Raj is offline Member
    Join Date
    Jul 2012
    Posts
    2
    Rep Power
    0

    Default Re: Java Eclipse error java.lang.ArrayIndexOutOfBoundsException

    how u got ..could u pls explain ???

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,981
    Rep Power
    21

    Default Re: Java Eclipse error java.lang.ArrayIndexOutOfBoundsException

    Forum Rules
    Guide For New Members
    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 CLOSED
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Replies: 4
    Last Post: 10-02-2011, 08:29 PM
  2. Replies: 1
    Last Post: 09-27-2011, 06:47 PM
  3. Replies: 1
    Last Post: 11-20-2009, 08:58 PM
  4. Replies: 1
    Last Post: 07-31-2007, 11:47 PM
  5. Replies: 1
    Last Post: 07-25-2007, 10:55 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •