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 trialAlex Roach
Front End Web Development Techdegree Student 5,499 PointsString member variable
Challenge: "Now add a String member variable named mTitle. Make it public."
public String mTitle() { }
Could anyone tell me what I'm doing wrong?
7 Answers
Stone Preston
42,016 Pointsit looks like you created a method, not a variable. (methods have () { } after them while variables do not). you can declare a public member variable like so:
public class SomeClass {
public dataType mVariableName;
}
you just need to declare the string variable named mTitle
public class PictureBook {
public String mTitle;
}
Jimmy Ma
5,796 PointsFor the Updated 2017 course:
public class PictureBook { public String title;}
This took me a little while to figure out.
luke moloney
2,347 PointsThx for the heads up Jimmy Ma!!
kwame Gyesi
900 Pointsthanks too
kwame Gyesi
900 Pointsthanks too
Shuvam Roy
656 PointsThanks.
MUZ141032 Yusuf Phiri
4,033 Pointspublic class PictureBook { public String mTitle;}
Oğuzhan İNCE
364 PointsOğuzhan İNCE
364 Pointsthanks