Results 1 to 5 of 5
  1. #1
    Azaz is offline Member
    Join Date
    Feb 2011
    Posts
    10
    Rep Power
    0

    Unhappy Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0 at wee

    I am getting the error,though i am writting correct code,please help me
    here is the code :-


    class week
    {
    public static void main(String args[])
    {
    int wd = Integer.parseInt(args[0]);

    /*By If
    if(wd==1)
    System.out.println("Sunday");
    else if(wd==2)
    System.out.println("Monday");
    else if(wd==3)
    System.out.println("Tuesday");
    else if(wd==4)
    System.out.println("Wednesday");
    else if(wd==5)
    System.out.println("Thursday");
    else if(wd==6)
    System.out.println("Friday");
    else if(wd==7)
    System.out.println("Saturday");
    else
    System.out.println("Invalid Day"); */

    /* By Switch Case */
    switch (wd)
    {
    case 1:
    System.out.println("Sunday");
    break;
    case 2:
    System.out.println("Monday");
    break;
    case 3:
    System.out.println("Tuesday");
    break;
    case 4:
    System.out.println("Wednesday");
    break;
    case 5:
    System.out.println("Thursday");
    break;
    case 6:
    System.out.println("Friday");
    break;
    case 7:
    System.out.println("Saturday");
    break;
    default:
    System.out.println("Invalid Day");
    }

    }

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Quote Originally Posted by Azaz View Post
    I am getting the error,though i am writting correct code,please help me
    here is the code :-

    Java Code:
    class week
    {
            public static void main(String args[])
            {
                    int wd = Integer.parseInt(args[0]);

    Perhaps you're writing correct code (I didn't look at it too closely to be hones since you didn't use code tags), but are you sure that you're calling it correctly? Are you passing any parameters to your program when you run it?

  3. #3
    Azaz is offline Member
    Join Date
    Feb 2011
    Posts
    10
    Rep Power
    0

    Exclamation

    I was not successfully run the program because of the error

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Quote Originally Posted by Azaz View Post
    I was not successfully run the program because of the error
    AGAIN: When you try to run the program, are you passing any parameters at all into it??

  5. #5
    Azaz is offline Member
    Join Date
    Feb 2011
    Posts
    10
    Rep Power
    0

Similar Threads

  1. Replies: 8
    Last Post: 03-05-2011, 03:53 AM
  2. Replies: 4
    Last Post: 10-13-2010, 09:19 AM
  3. Replies: 5
    Last Post: 04-05-2010, 02:28 PM
  4. Replies: 1
    Last Post: 11-20-2009, 07:58 PM
  5. Replies: 1
    Last Post: 07-25-2007, 10:55 PM

Posting Permissions

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