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 trial
Moses Williams III
28,802 PointsHangman Input
I want to throw an exception when the user enters in more than one character. I can't seem to find out how to accomplish this. Can anyone help me with this bug/feature? Thank you :)
1 Answer
Kyle Budd
7,821 PointsI found the easiest way to do this is to add an additional if statement to your applyGuess method:
if (letters.length() > 1) {
throw new IllegalArgumentException("Only enter 1 letter at a time");
}