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 Creating the MVP Remaining Characters

Henry Wang
Henry Wang
6,412 Points

Remaining Characters Compiler Problem

Hi Fellow Programmers,

I am really stuck on this code challenge but think that there's probably something wrong with the compiler. On step 2, I am instructed to return the MAX_CHARS variable minus the characters used. However, I would get the same error message every time I ran the code (Hmmm. what if in your remainingCharacterCount method you tried to use the MAX_CHARS constant minus the length of the text?) I am 99% sure that there is nothing wrong with my code or logic (I have tried multiple variations of the same logic many times but saw the same error message).

I have attached my code below. Thank you for your help in advance!


public class Tweet {
  private String text;
  public static final int MAX_CHARS = 140;  

  public Tweet(String text) {
    this.text = text;

  public String getText() {
    return text;

  public void setText(String text) {
    this.text = text;

    public int getRemainingCharacterCount() {
        return (MAX_CHARS - getText().length());


1 Answer

Luca Cunico
Luca Cunico
Courses Plus Student 14,196 Points

Hi, your code is correct.

However the coding challenge is expecting this: (MAX_CHARS - text.length());