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 (Retired) Creating the MVP Strings and Chars

Shubham Modi
Shubham Modi
5,799 Points

Where am I going wrong

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 class ScrabblePlayer {
    private String mHand;

    public ScrabblePlayer() {
        mHand = "";

    public String getHand() {
       return mHand;

    public void addTile(char tile) {
         mHand += tile;
        // Adds the tile to the hand of the player


    public boolean hasTile(char tile) {
       if(indexof(mHand) == 1){
         return true;
       return false;

1 Answer

Kourosh Raeen
Kourosh Raeen
23,733 Points

The method hasTile() should return true not just if indexOf() returns 1, but if it returns and number that is greater or equal to 0.