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

java objects

Welcome to a little Twitter-like application. Here I'm modeling a Tweet. It has text which is the body of the tweet. All Tweets have a maximum character limit of 140 characters.

Please add a new constant to store the maximum number of characters allowed which is 140. Use the proper access level modifiers to make it unchangeable and accessible right off of the class. Follow the proper naming convention.

Tweet.java
public class Tweet {
  private String mTweet;

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

  public String getTweet() {
    return mTweet;
  }

}

the above code shows a bummer. "the constant should be marked public " can anyone help

3 Answers

Yongshuo Wang
Yongshuo Wang
5,500 Points
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;
  }

}

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

public Tweet(String text) { mText = text; }

public String getText() { return mText; }

}

thanx bro