Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

array indexoutof bounds  RSS feed

 
archu sweet
Ranch Hand
Posts: 66
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

And the command-line invocations:
java Input
java Input 0


with the given input the code produces two exceptions ....I need to know with the first command-line invocations as java Input why does the code produce array indexoutof bounds....???

usually An ArrayIndexOutOfBoundsException happens when an index is used that is smaller than zero, or larger than or equal to the size of the Vector..Please help me out...thanks in advance....This code was taken from kathy sierra scjp 1.5
 
fred rosenberger
lowercase baba
Bartender
Posts: 12542
48
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I edited your code tags to try and make your post easier to read (you pasted AFTER the tags, you need to paste BETWEEN them). However, since your code isn't properly indented, it didn't do much good.

Also, it helps if you post the actual error message, exactly as it appears.

I'm guessing (since you did not post it) that you get an error on line 5 when you invoke with "java Input". When you do that, there is nothing in the args[] array. I am not even sure the array would be created. So when you try and access args[0], you are out of bounds. There is no zeroeth element, because there are NO elements.
 
archu sweet
Ranch Hand
Posts: 66
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@ fred rosenberger :Thanks :-D
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!