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

David Sampimon
David Sampimon
12,026 Points

Cannot find symbol error on text.length()

I am getting a cannot find symbol error on text.length() and I don't understand why.

In this excersise I need to provide a method which shows the number of charachters left in a tweet.

Therefore I created the 'getRemainingCharacterCount', which simply returns the maximum characters minus the length of the text string: text.length()

Why won't this code compile?

Tweet.java
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 - text.lenght();
  }


}

2 Answers

andren
andren
28,558 Points

Because you have a typo in the word length, you have written it as lenght (the last two letters are swapped). If you fix the typo your code should work.

David Sampimon
David Sampimon
12,026 Points

Wow, I have been looking so long at the code without noticing the typo :|

Thank you!