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 trialJohn Amadeo
5,546 PointsTrouble adding a member variable
Hi! I'm stuck on a code challenge asking me to:
"Now add a String member variable named mTitle. Make it public."
I typed in:
public class PictureBook { public String mTitle() { } }
but I keep getting told I'm wrong. I've checked Ben's video multiple times and I seem to have written the code exactly the way he wrote it and yet I've somehow still gotten the code wrong.
Can anyone please help me if they've identified an error in my code? Apologies if my mistake was very basic, this is my first time ever making an app.
Thanks!
public class PictureBook {
public String mTitle() {
}
}
3 Answers
Mikael Enarsson
7,056 PointsThey are asking you to make a public member variable, what you have there is a public member function declaration (I think that's the right word).
Drop the parentheses and the curlies and add a semicolon to the end and it should be fine ^^
Edit: Oh, I should clarify, only remove the curlies extending from mTitle, not the ones from the class.
John Amadeo
5,546 PointsFollowed your advice and it worked. Thanks so much for the help Mikael! Much appreciated!
Mikael Enarsson
7,056 PointsDe rien ^^ Happy to be of help!
MUZ140899 Sheunesu Mujakachi
4,272 Pointsthanx a lot was stuck