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 trialHenry Wang
6,412 PointsRemaining Characters Compiler Problem
Hi Fellow Programmers,
I am really stuck on this code challenge but think that there's probably something wrong with the compiler. On step 2, I am instructed to return the MAX_CHARS variable minus the characters used. However, I would get the same error message every time I ran the code (Hmmm. what if in your remainingCharacterCount method you tried to use the MAX_CHARS constant minus the length of the text?) I am 99% sure that there is nothing wrong with my code or logic (I have tried multiple variations of the same logic many times but saw the same error message).
I have attached my code below. Thank you for your help in advance!
Henry
public class Tweet {
private String text;
public static final int MAX_CHARS = 140;
public Tweet(String text) {
this.text = text;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public int getRemainingCharacterCount() {
return (MAX_CHARS - getText().length());
}
}
1 Answer
Luca Cunico
Courses Plus Student 14,196 PointsHi, your code is correct.
However the coding challenge is expecting this: (MAX_CHARS - text.length());
Henry Wang
6,412 PointsHenry Wang
6,412 PointsThank you!