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 trialBenneth Paredis
4,597 Pointsplease help me with this excercise
what am i wrong ..... please explain
public class Tweet {
private String mText;
private static final MAX_LETTERS;
public Tweet(String text) {
while (text < 140) {
String text = console.readline ("Enter your tweet here: ");
mText = text;
}
}
public String getText() {
return mText;
}
}
1 Answer
akin
Courses Plus Student 2,865 PointsHi Benneth ;
If you use constructor method for your class, don't use loop statements inside it. Constructor methods are used for initializing objects with some special values (prepare objects with initial values) etc... If you want to get messages from users, you can use another method for this (not constructor method if you want to use this method repeatedly. But in your code example , if entered text (text is also string not integer) parameter is smaller than 140, console.readline method is called repeatedly. If you want to control message length , you can use string length method. If text length more than 140, then another message can be sended to user or whatever if you want... Don't use constructor method parameters for this logical step, because of constructor method is only one time called when you create a new object
Benneth Paredis
4,597 PointsBenneth Paredis
4,597 Pointsthanks , this really helped !