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!

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 (Retired) Creating the MVP For Each Loop

Alexandru Constantin Sirbu
Alexandru Constantin Sirbu
3,419 Points

Error says I forgot to add the method getTileCount that accepts chars:

I don't understand what I'm doing wrong. I think I'm missing something. If someone could take a look at my code and give me some tips that would be great

public class ScrabblePlayer {
  private String mHand;

  public ScrabblePlayer() {
    mHand = "";

  public String getHand() {
   return mHand;

  public void addTile(char tile) {
    // Adds the tile to the hand of the player
    mHand += tile;
public String getTileCount()
    String count = "";
    for (char tile: mHand.toCharArray())
      String displayCount = "";
      if (mHand.indexOf(tile) >= 0)
       displayCount += tile;
      count += displayCount;
    return count;
  public boolean hasTile(char tile) {
   return mHand.indexOf(tile) > -1;

1 Answer

Jennifer Nordell
Jennifer Nordell
Treehouse Teacher

Here's a couple of hints. The function getTileCount should return an integer and accept a character. Right now yours returns a String and accepts nothing. The declaration of the function should look like this:

public int getTileCount(char tile)

Not long ago I posted a rather detailed explanation and solution to this challenge. If you still need assistance you can find it here: https://teamtreehouse.com/community/help-to-solve-code-challenge-also-please-explain-the-logic-and-thanks-in-advance