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 trialHenry Yang
Java Web Development Techdegree Student 8,343 PointsIt seems that the code does not check input like "tr" or "tree" which has more than 1 letter
As described in the title, it seems that the code does not check input like "tr" or "tree" which has more than 1 letter. So we assume these cases are legal and just check the first character?
1 Answer
andren
28,558 PointsYour question is not attached to a particular video or challenge, but if you are asking about the Hangman game in the Java Objects course then the answer is yes, your conclusion is correct.
On this line:
char guess = guessInput.charAt(0);
You are pulling out the first letter of the guessInput
string, which is the string that contains the guess that was entered. So regardless of how many letters are entered only the first one will be treated as the guess.