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

I dont know whats wrong with this problem it keeps giving me an error, Bijan

this problem I believe is correct but it keeps giving me an error, Bijan

2 Answers

Hi Bijan,

I'm not sure which part of the challenge you are on, so I'll walk through it all.

The first is asking you set a constant for the max character limit of 140. That can look something like:

public static final int MAX_CHARS = 140;

You can call that whatever you like, but keep it relevant! Next we need to return the remaining characters using the constant we just defined and the length of the existing mText property. This is in its own method which, again, you can call what you like.

My code looks like:

  public int charsRemaining(){
    return MAX_CHARS - mText.length();
  }

There, the charsRemaining method returns an integer value and takes no parameters. The value returned is the difference between the constant (140) and the result of calling the length() method on the mText field.

I hope that helps.

Steve.

yeah there was an error, i did the code like before, i got hints too to get the answer but i had some things correct before that though, but now it just let me pass...i think there was an error with the site...thanks for your help though Steve, I see you help alot of people I got some hints from your helping others also...thanks alot, Bijan