Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ArrayIndexOutOfBoundsException error

 
Yohan Weerasinghe
Ranch Hand
Posts: 507
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Pramod P Deore
Ranch Hand
Posts: 632
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Yohan Weerasinghe
Ranch Hand
Posts: 507
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the replies. I really appreciate that help.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic