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 trialAbe Daniels
Courses Plus Student 2,781 PointsThis is a lot to ask!
So I already know I need to create a new method, and that in the method I will be getting the value of characters from the Tweet which I think means I will use a .atCharArray. I'm not sure if I'm supposed to attach that to the method name, or to something else.
public class Tweet {
private String mText;
public static final int MAX_CHARS = 140;
public Tweet(String text) {
mText = text;
}
public String getText() {
return mText;
}
}
1 Answer
Ken Alger
Treehouse TeacherAbe;
Welcome to Treehouse! Let's take a look:
Task 2
Add a new
method
thatreturn
s the remaining characters available, based on thelength
of what is currently stored inmText
.
I'm going to assume that by this point in the course you have a strong understanding of what creating a method and returning data means and the way in which one can do that in a general sense. For this challenge it sounds like we want to return
the number of characters still available. That sounds like an int
type and it should be the number of characters left.
For example, our max Tweet is 140 characters, if the length
of our current text
is 100 characters our method should return 40, correct (140-100) ? See if you can use that hint to get through the task.
Post back if you're still stuck.
Ken