Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialKami Ellis
645 PointsMy code won't return if I got a hit or a miss. all I get is an error. Any help is appreciated.
this is the error I an getting:
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 48
at java.lang.String.charAt(String.java:658)
at Prompter.promptForGuess(Prompter.java:14)
at Hangman.main(Hangman.java:7)
I have no idea what it means.
Any and all help is greatly appreciated.
Kami Ellis
645 PointsThis is my code: https://teamtreehouse.com/workspaces/41308746 Hopefully this link will work.
Steven Parker
231,269 PointsYou can't share a direct URL to your workspace, it's temporary and only exists while you are using it. But as I suggested before, you can use the snapshot function in the workspace and provide the link to that.
2 Answers
Steven Parker
231,269 PointsIn "Prompter.java", on line 14 the "charAt" method is being called with a character argument of '0'.
But the argument to "charAt" should be a number value (no quotes).
Kami Ellis
645 PointsIt worked! Thank you so much!
Kami Ellis
645 PointsThis is the snapshot of my code: https://w.trhou.se/3t2dwzin23 I think this link will work. Sorry for all the trouble.
Steven Parker
231,269 PointsSteven Parker
231,269 PointsWe'd need to see the code, either posted with Markdown formatting, or you could make a snapshot of your workspace and post the link to it here. A link to the course page you are working with would also be helpful.