• Post Reply Bookmark Topic Watch Topic
  • New Topic

Beginning Java RingBuffer Code Error  RSS feed

 
Jackie Dyer
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I keep getting this error for my RingBuffer Code for GuitarHero:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at RingBuffer.main(RingBuffer.java:80)

What am I doing wrong?

 
Stefan Evans
Bartender
Posts: 1837
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First thing you're doing wrong: You forgot to UseCodeTags to make your post more readable

ArrayIndexOutOfBounds normally means you are referring to an item outside of the valid range.
It tells you the index it couldn't access (0)
So which array are you accessing on this line of code, and why would it not be big enough to take even one entry?


EDIT: Just went and edited your post to add the code tags. You had the tag present, you just needed to put your code BETWEEN the open/close code tags

Now that it has line numbers: this is the line of code I presume it is complaining about :



How are you running this program? You need to pass an argument via the command line / run configuration for this program to work properly.
 
Campbell Ritchie
Marshal
Posts: 56518
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
…and if you don't pass any arguments you get an out of bounds exception for index 0. Use this format for the main method
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!