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

Java Java Objects Creating the MVP Prompting for Guesses

3 Answers

ALBERT QERIMI
ALBERT QERIMI
49,872 Points

to retrieve just first letter that you get from guess input

any character sequence in java use zero based position so the first is 0 then 1,2,.... so for example

char c = "hello".charAt(0); // c = 'h'

h is 0, e is 1 and so on in counting so we extract the first letter by telling it to give us the letter at the position zero (give us the char at the position number)

ALBERT QERIMI
ALBERT QERIMI
49,872 Points

Yes, in this case, we are checking just for the first letter because one letter for guess that is all we need in this case