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 trialMaksims Visnakovs
2,616 PointsHey in Build a simple Android App challenge I was asked to add s String member with a variable mTitle and make it public
Here is the code: public class PictureBook { public String mTitle() {} }
public class PictureBook {
public String mTitle() {}
}
Grigorij Schleifer
10,365 PointsHey Maksims,
do you need more help?
Grigorij
1 Answer
Grigorij Schleifer
10,365 PointsHey Maksims,
you are quite close !
Lets dive into the final code of the challenge. Therefor I have modificated and commented your code.
public class PictureBook {
// here you are making a new class
// its public, so everyone can use it
// the name is uppercased, because the class name has to be uppercased in Java
//the class must have two { }
//one after the class name and the second closes the whole code at the end
public String mTitle;
//here yoa are declaring a public String variable
// its public and visible for everyone
// the name of the variable is mTitle
//lowercased m stands for member variable
// its an Android naming convention thing, you will learn more about this in next courses
// after declaration you must use ;
// so the compiler knows where the declaration ends
}
Stay tuned and shout out if you need more help
Grigorij
Grigorij Schleifer
10,365 PointsGrigorij Schleifer
10,365 PointsIf you have troubles to understand the whole concept.
Why there is a ; Or why here is a {
Dive into the java course. I want to programm for Android but I am on the Java track for 5 month until now. It gives you the necessary basic Java understanding that is quite important for Android programming.
Grigorij