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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Joanna van der Veen](https://secure.gravatar.com/avatar/0423e9b3f19e821e631394e835a68af9?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Joanna van der Veen
543 PointsKeep getting 'missing return statement' error
Hi,
I've followed along with the video but I keep getting an error and can't see how to solve it:
public boolean applyGuess(char letter) { // This creates a method that returns a true or false value depending on whether the input, which is a letter, is in the answer or not. It defines what should happen in each case. letter = validateGuess(letter); boolean isHit = mAnswer.indexOf(letter) >= 0; if(isHit) { mHits += letter; } else { mMisses += letter; } return isHit; }
Sorry, I couldn't figure out how to get a screenshot on here..
Any help much appreciated!
3 Answers
![Jeremy Hill](https://uploads.teamtreehouse.com/production/profile-photos/786242/micro_WIN_20151126_150956__2_.jpg)
Jeremy Hill
29,567 PointsIf it were me I would do this code a little differently:
boolean isHit = mAnswer.indexOf(letter) >= 0;
I would do it something like this:
boolean isHit;
if(mAnswer.indexOf(letter) >= 0)
isHit = true;
else
isHit = false;
![nihouse](https://uploads.teamtreehouse.com/production/profile-photos/4955222/micro_20130601_143753.jpg)
nihouse
7,160 PointsWhen you get en error, please always post it here. And also post other parts of your code, because from first view, the code looks ok.
For formatting, look at the "Markdown Cheatsheet" (link below the field where you write your post/question). For java write "java" where you findd "html" in the exmple of the Markdown Cheatsheet.
![nihouse](https://uploads.teamtreehouse.com/production/profile-photos/4955222/micro_20130601_143753.jpg)
nihouse
7,160 PointsOh sorry, I overlooked the title of your post, because I clicked on the little notification link.
Jeremy Hill
29,567 PointsJeremy Hill
29,567 PointsI will show you how to format your code: If you type something other than code before your code go ahead and hit enter and follow these instructions:
Type in the accent key that is above the Tab key three times in a row followed by the keyword java and hit enter twice. Next, with at least one space in between type the accent key three more times and then hit enter. Next copy and paste your code in between the accent marks and then submit.