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
Joseph Wasden
20,407 PointsJava, For Each loop challenge
This is a bit silly, but I just can't seem to figure out why this isn't working.
For the Java Objects For Each loop challenge, I keep getting error: cannot find symbol in my if statement for the first 't' in "tile." I'm not sure why.
Any insight?
public int getTileCount() {
int count;
for (char handTile : mHand.toCharArray()) {
if (tile == handTile) {
count++;
}
return count;
}
}
1 Answer
Blake Larson
13,014 PointsYup Alen is right. It's not asking how many tiles are in mHand, but how many tiles in mHand match the passed in tile.
Alen Sabic
Python Web Development Techdegree Student 2,603 PointsAlen Sabic
Python Web Development Techdegree Student 2,603 PointsI'm pretty sure you have to pass in a tile parameter in the method header.
So try public int getTileCount(char tile){ //body code }