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 trialDean Onizuka
4,753 Pointstask 2 for scrabble game java
can anyone tell me why this does not work for
"Can you also please help me write out the hasTile method? It should return true if the hand has the tile, and false if it doesn't. Thanks!"
public boolean hasTile(char tile) {
if (mHand.indexOf(tile)) >= 0; {
return true;
} else {
return false;
}
}
2 Answers
Craig Dennis
Treehouse TeacherYour paren should be after the >= 0
not before it, also no semi-colon there.
Hope it helps!
Lee Reynolds Jr.
5,160 PointsIn the example they both follow the same basic rule that I have noticed. When you are opening a block of code using the "{" you do not use a ";". Also I have noticed that whenever you are opening a new block of code using the curly brackets, you almost always use parens. I'm also a beginner but that's what I have noticed, my word isn't law :) Happy Coding
Dean Onizuka
4,753 Pointsahh i'll keep that in mind. thanks. java seems to be a lot of trial and error lol
Lee Reynolds Jr.
5,160 Pointshaha yeah I've noticed that. I have a lot of errors that I have to take the time and figure out but with the help of Craig and all of the other treehouse team members, you'll always come out on top. The forum is also very very helpful, for it shows people of all levels of learning coming together and sharing their personal encouraging thoughts and ideas to make this thing work. I love this place and I am happy for other students like you on the team.
Dean Onizuka
4,753 Pointsfor sure. thanks for the input. i'll definitely be seeing you around on the forums
Dean Onizuka
4,753 PointsDean Onizuka
4,753 Pointssorry if this is a dumb question but why the change of syntax between this 'if/else' statement in the challenge exercise and the 'if/else' statement for the hangman game.
in this instance only the letter is surrounded by parens. also there is a semi colon at the end of the >=0. just wondering since i know java is very specific.