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

New method that returns the remaining characters available, based on the length stored in Text.

Hello, It says i need to try again. I cannot find my failing point. Please help me locate what i am doing wrong here

Here's the code:

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

public Tweet(String text) { mText = text;

}

public String getText() { return mText; }

public int remCharAvailable (){ remChar = MAX_CHARS - mText.length(); return remChar; }

}```

3 Answers

You might as well return the expression straight away: return MAX_CHARS - mText.length();

I think you just need to declare remChar as an int. { int remChar = MAX_CHARS - mText.length(); return remChar; }

Thank you, Pedro, that actually worked.