And the command-line invocations:
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
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, you are out of bounds. There is no zeroeth element, because there are NO elements.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors