wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes ArrayIndexOutOfBoundsException error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "ArrayIndexOutOfBoundsException error" Watch "ArrayIndexOutOfBoundsException error" New topic
Author

ArrayIndexOutOfBoundsException error

Yohan Weerasinghe
Ranch Hand

Joined: Oct 07, 2010
Posts: 499

Hi all,

I have created a very small java application but that gives me an error "Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0". Please help me to find the error. here is the code.


Are you better than me? Then please show me my mistakes..
Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

Hi, you must have to provide 3 arguments at the runtime. You must have to run program like
java candidate pramod deore 123

And check output.

Life is easy because we write the source code.....
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

You need to invoke this program with commandline parameters. Otherwise the array will have a size of 0 and you're trying to access an element which results in an ArrayIndexOutOfBoundsException. You need to do something like

java candidate 1 wouter 4-3-2011

And by the way classnames should begin with an uppercase character.


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Yohan Weerasinghe
Ranch Hand

Joined: Oct 07, 2010
Posts: 499

Thanks for the replies. I really appreciate that help.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ArrayIndexOutOfBoundsException error