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 trialanthony rweyemamu
1,756 Pointsplease help me to "add a String field (member variable) named mTitle adnd Make it public."
none
public class PictureBook {
public String mTitle() {
String[] title= {};
return title;
}
}
1 Answer
andren
28,558 PointsMember fields / variables are pretty much just a variable that is a part of a class instead of a method. As such you also define them pretty much exactly like you would a regular variable, not like a method like you are attempting.
public class PictureBook {
public String mTitle;
}
As you can see besides the public keyword it looks just like any other variable declaration, you can also set the member variable as you define it with the equals sign just like you can with a regular variable. But the challenge does not ask for that so I do not show that above.
anthony rweyemamu
1,756 Pointsanthony rweyemamu
1,756 Pointsthanks! i'm just not getting the hang of it yet....