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 Remaining Characters

Adam Duffield
Adam Duffield
30,494 Points

Problems with code for the final code challenge on Java Objects

Here is my code... I'm just having issues with thinking that I've got the right code but it's telling me that I'm wrong, I just have to return the length of the text if it's less than 140 characters but I must be missing something.

public class Tweet {
  private String mText;
  public static final int MAX_TWEETS = 140;
  public Tweet(String text) {
    mText = text;
  }

  public String getText() {
    return mText;
  }
  public int doStuff(){
    if(mText.length() < MAX_TWEETS){
      return mText.length();
    }

  }

}

What's your error?

1 Answer

It doesn't look like there's an error there at all. Are you sure that's all the question is asking you to do?

That's not what it's asking you to do. It's asking you to return the difference between the MAX_TWEET and the text in mText. You want to subtract mText from MAX_TWEET, then return the result.

Adam Duffield
Adam Duffield
30,494 Points

haha! perfect cheers for that comment Nicolas, it's kind of nice to know that I'm all good on the coding side but lacking on my reading skills!