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 trialSlava Fleer
6,086 Pointshello. could you rephrase the first exercise, please? I didn't understand what i need to finish it. thanks.
hello. could you rephrase the first exercise, please? I didn't understand what i need to finish it. thanks.
5 Answers
Nikolay Egov
96 PointsA constructor is a method with the same name as the class and return nothing. So what you have written is just a normal method. If the class is Forum them the constructor should be something like: public Forum (String someString) { //code goes here mTopic = someString; }
Ben Morse
6,068 PointsThis works. Thanks!
Ivan Sued
5,969 PointsWhat the task is asking you is to create a constructor that takes a string as a parameter in the forum class aka. Forum.java. It is the third file from the left.
The Constructors are the initial method that is called when a instance is created. The have the same name as the class.
Hope that helps
Slava Fleer
6,086 Pointsthanks. i would check it later.
Slava Fleer
6,086 Pointsstill didn't get it =(
what i added is :
public void addTopic(String topic){ mTopic = topic; }
and i received next error:
Bummer! Did you add a new constructor that takes accepts a string?
any help ?
Ivan Sued
5,969 PointsMake sure to name the constructors as I mentioned on my original answer and how Nikolay mentioned. Constructors have the same name as the class and return nothing.
Juan Santiago
3,766 PointsI had the same problem, I don't know why exactly but the only thing that fixed it was removing the "void" part. Like:
public Forum (String theTopic) { mTopic=theTopic; }
Neelesh Tewani
1,239 Pointshi i am neelesh i want to know how to do the fouth task in this challenge
Slava Fleer
6,086 PointsSlava Fleer
6,086 Pointshello. could you rephrase the first exercise, please in Android Development->Stage 4 Delivering the MVP -> Wrapping UP ? I didn't understand what i need to finish it. thanks.