Results 1 to 2 of 2
  1. #1
    hyma19 is offline Member
    Join Date
    Jan 2012
    Posts
    1
    Rep Power
    0

    Default problem with ArrayIndexoutofbounds exception

    Hi,
    I am new to java ... i am facing the problem with ArrayIndexOutofBounds Exception..
    class Maxof2{
    public static void main(String args[])
    {
    //taking value as command line argument
    //converting the string format to integer value.
    int i=Integer.parseInt(args[0]);
    int j=Integer.parseInt(args[1]);
    if(i>j)
    System.out.println(i+"is greate than "+j);
    else
    System.out.println(j+"is greater than"+i);
    }
    }
    Anyone can help me out...

    Thanks in Advance,
    Hyma

  2. #2
    Join Date
    Dec 2010
    Location
    pune
    Posts
    1
    Rep Power
    0

    Default Re: problem with ArrayIndexoutofbounds exception

    your code expecting at least two values from command line.

    as array args[] do not have values for index 0 or 1 ,the code is throwing the exception

Similar Threads

  1. Replies: 4
    Last Post: 04-14-2011, 07:45 AM
  2. ArrayIndexOutofBounds Exception on an Excel File
    By CrashWave in forum New To Java
    Replies: 3
    Last Post: 03-01-2011, 08:44 PM
  3. ArrayIndexOutOfBounds, JTable.getValueAt
    By ZackO in forum AWT / Swing
    Replies: 10
    Last Post: 10-17-2010, 07:29 PM
  4. ArrayIndexOutofBounds Exception
    By atul.goldenstring in forum New To Java
    Replies: 10
    Last Post: 04-10-2010, 10:47 AM
  5. ArrayIndexOutOfBounds
    By SwEeTAcTioN in forum New To Java
    Replies: 6
    Last Post: 12-07-2009, 12:59 AM

Posting Permissions

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