• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

array indexoutof bounds

 
Ranch Hand
Posts: 66
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
lowercase baba
Posts: 13082
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@ fred rosenberger :Thanks :-D
 
Everybody's invited. Except this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic