Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Java Objects (Retired) Creating the MVP Strings and Chars

i'm not sure what's he's asking but can i please see the code for this question like what does he mean my hand which

I don't understand what he's asking by the way that he's asking it

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) {
       return false;

1 Answer

Walter Allen
Walter Allen
iOS Development with Swift Techdegree Student 16,023 Points

Hey, Donta... It appears that you have complete the first task in the challenge correctly by adding the char tile to the string mHand. Are you talking about the second part of this challenge? I couldn't quite tell from your question.

If so, you need to use the indexOf method to find out if the char tile is in the String mHand. The indexOf method will return the index of the char in the String, OR if it doesn't exist, will return -1. There are several ways to do this. One way would be to write

if (mHand.indexOf(tile) >= 0) {
     return true;

return false;

You can do it a couple of other ways as well, but they all involve the same concept. Does that help?

Simon Coates
Simon Coates
28,693 Points

Starting out, you should probably favourite the string documentation. Reading it, the methods that jump out are indexOf and contains. You should be aware that String objects are of type CharSequence. So a method that says CharSequence should be able to accept a string.