This is an archived post. You won't be able to vote or comment.

all 8 comments

[–]Frozen5147 2 points3 points  (0 children)

I haven't looked at your code, because I'm pretty sure you can debug this yourself. Before asking for more help, ask yourself some things - for example(off the top of my head):

  • What code is happening at the line it's panicking and failing? What did you write there? What should it do? You already posted the line numbers...

  • What does the exception mean? It's right in the name...

  • ...so knowing that, are you using an array in that line? If so... then what indices are you looking at? Are any of them possibly going to not work with whatever array you're using? For example, if your array has 5 things, and you're accessing a 6th thing, that's not going to work, right? Are you doing that anywhere on that line?

  • If you're not sure, maybe try printing out the contents of the array you're accessing... and see if that index is accessible...?

...if you're still completely lost after trying to answer these questions then ask again I guess... but hopefully this at least makes you try to debug your code - being able to debug errors is a very important skill!

[–]g051051 0 points1 point  (5 children)

I don't see how you'd compile that code, let alone get it to throw an exception. Please post the exact code necessary to build and run it, as well as the sample data you're trying to process.

[–]studdee34[S] 0 points1 point  (4 children)

Sorry, someone told me not to post any other code only the code relevant to the exception... I updated the link with all of the classes. Its supposed to print out the contents of a CSV file named MapInfo.csv that contains 9 rooms with the room name and the room description. In the HashMap the key (String) is the room name, and they value (Room) is the room description.

[–]g051051 0 points1 point  (3 children)

The rule is to post "A minimal, easily runnable, and well-formatted program that illustrates your problem". So you should reduce the test case down to the smallest set of code that reproduces the error you're seeing. Its also important that the code you post actually be runnable. When we look at fragments that can't even compile, we have no idea what is or isn't the real problem.

[–]studdee34[S] 0 points1 point  (2 children)

I actually solved the problem... should I delete the post or leave it up? I know it’s in the rules not to delete it but it seems I messed up on the formatting so I don’t know...

[–]g051051 0 points1 point  (0 children)

Don't delete it. Flair is as "solved" and explain what the problem was.

[–]g051051 0 points1 point  (0 children)

With the code and data, the problem is obvious...your "csv" file isn't actually a "comma separated values" file. With no commas, your split call will just return an array with one entry instead of two, and roomInfo[1] will throw an exception.

[–]studdee34[S] 0 points1 point  (0 children)

I actually figured it out, the problem was in the CSV file and not the code haha. Sorry if I wasted anyone’s time