• Post Reply Bookmark Topic Watch Topic
  • New Topic

What am I doing wrong? (TreeMaps and ArrayLists)  RSS feed

 
john kidwell
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My prompt is to use the text files:



and



and get this output:



But my output is coming out like this:


What am I doing wrong??

Here's my code:


 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
john kidwell wrote:
But my output is coming out like this:


What am I doing wrong??


The stacktrace is saying... in Sport.java, at line 40, is the main() method of the Sports class. At that line, an array is accessed using an index of 2. Unfortunately, the array doesn't have an index of 2, likely because the array is smaller in size.

You need to go to that line, and figure out why the array access is out of bounds -- either the array is created of the wrong size, or the index calculated is wrong.

Henry
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!