Virtual Position Forum
Please register to watch content in detail
Thanks
Admin virtual position


Join the forum, it's quick and easy

Virtual Position Forum
Please register to watch content in detail
Thanks
Admin virtual position
Virtual Position Forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Why it is not working "CmdLineArgsApp.class"

View previous topic View next topic Go down

GMT + 3 Hours Why it is not working "CmdLineArgsApp.class"

Post by Diya Sun May 29, 2011 4:02 pm

AOA Sir,

Here is the message when run the "java CmdLineArgsApp"
D:\java>java CmdLineArgsApp
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at CmdLineArgsApp.main(CmdLineArgsApp.java:7)
What is wrong with it?
Diya
Diya
Monstars
Monstars

Taurus Goat
Posts : 364
Join date : 2011-02-08
Age : 33
Notworthy

Character sheet
Experience:
Why it is not working "CmdLineArgsApp.class" Left_bar_bleue10/500Why it is not working "CmdLineArgsApp.class" Empty_bar_bleue  (10/500)

Back to top Go down

GMT + 3 Hours Re: Why it is not working "CmdLineArgsApp.class"

Post by Vuhelper Sun May 29, 2011 4:03 pm

When while running CmdLineArgsApp you do not provide any command line arguments you get this exception.

Because in the code args[0] and args[1] are being used , if we do not provide any argument at command line, args[0] and args[1] do not have any value and exception is generated.

You can place a check to avoid this exception, you can check for number of element (i.e. check the value of args.length ) in args array if they are greater then 0 then proceed futher.
avatar
Vuhelper
Deep Bench
Deep Bench

Posts : 97
Join date : 2011-05-29

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

Permissions in this forum:
You cannot reply to topics in this forum