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 trialkangan kapoor
Courses Plus Student 374 PointsJava Objects.
Add a new method to return the remaining characters based on length of mText.
public class Tweet {
public static final int MAX_LENGTH = 140;
private String mText;
public Tweet(String text) {
while (text.length() < MAX_LENGTH) {
mText = text;}
}
public String getText() {
return mText;
}
public int getRemainingChars() {
return MAX_LENGTH - mText.length();
}
}
2 Answers
Kourosh Raeen
23,733 PointsHi Kangan - There is nothing wrong with your code. I just tried it and it passed. Give it another try.
kangan kapoor
Courses Plus Student 374 PointsI m still getting BUMMER!! Try Again. I dont know what the problem is, and I cant go any further in the Java Objects till i clear this. Please suggest.
Kourosh Raeen
23,733 PointsOK, the problem is in the constructor. I'm not sure why you have while loop there but change that back to the original code:
public class Tweet {
public static final int MAX_LENGTH = 140;
private String mText;
public Tweet(String text) {
mText = text;
}
public String getText() {
return mText;
}
public int getRemainingChars() {
return MAX_LENGTH - mText.length();
}
}
kangan kapoor
Courses Plus Student 374 PointsThanks a lot Kourosh, it worked.
kangan kapoor
Courses Plus Student 374 Pointskangan kapoor
Courses Plus Student 374 PointsWhat is wrong in the code???