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

Joshua O'Brian
Joshua O'Brian
20,747 Points

Java Objects

Not sure what is going on. This is one example of all the ways I've tried, my code isn't showing any errors all I do is get Try again!... I've looked at the forms for help after getting this problem, but what everyone else is saying passes doesn't.

2 Answers

Hi Joshua,

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 goes inside the class. 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 - let me know if not and we can have another look.

Steve.

Joshua O'Brian
Joshua O'Brian
20,747 Points

That's what mine looks like and it does not work.

Joshua O'Brian
Joshua O'Brian
20,747 Points

lol. it must of hated me last night or I was to tired to function cause I just redid it and it worked.

Glad you got it fixed! :-)

Krzysztof Kucharzyk
seal-mask
.a{fill-rule:evenodd;}techdegree
Krzysztof Kucharzyk
Front End Web Development Techdegree Student 4,005 Points

I understand in this challenge you have to add a public class, make it max char limit to 140 and use proper access level modifier. Try to add this line inside public class Tweet above private String mTweet;

  public final static int MAX_CHARACTER_LIMIT = 140;
public class Tweet {
  public final static int MAX_CHARACTER_LIMIT = 140;

  private String mTweet;

  public Tweet(String tweet){
    mTweet= tweet;
  }

  public String getTweet() {
    return mTweet;
  }

}