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 trialAbobaker Alkandery
655 PointsChallenge task error - Simple Android app
//Challenge Task 2 of 2
//Now add a String member variable named mTitle. Make it public.
public class PictureBook{
public String mTitle(){
String Title="lkjokj";
return Title ;
}
}
// Bummer! Make sure you are declaring a member variable in the class named 'mTitle'. Preview Get Help Recheck work
4 Answers
Ben Jakuben
Treehouse TeacherHey Aboobaker, you had most of the correct code in your original post. What happens if you replace this code:
(){
String Title="lkjokj";
return Title ;
}
with just a semicolon? Adding a member variable should only be one line of code. Parentheses and curly braces are for methods, not single variables. :)
Abobaker Alkandery
655 PointsIt's work :)
thanks a lot coach Ben
Ismael Soumahoro
6,410 Pointswhat do you mean with just a semicolon?
Ben Jakuben
Treehouse TeacherIsmael Soumahoro , the code I highlighted above isn't needed for this challenge. Declaring a member variable just needs three words and a semicolon. Check out the 2:50 mark of this video. The example in the video is for a TextView
member variable, but in the challenge it just needs to be a String
variable.
Hendy Budhigraha
17,328 PointsMaybe you can try the following code:
public String mTitle;
Abobaker Alkandery
655 PointsThanks for helping
I tried your answer, but it's not work.
code:
public class PictureBook{
public String mTitle;
{
return mTitle;
}
}
Ayaz Parwaiz
Courses Plus Student 2,284 PointsDear Aboobaker,
Syntax for member variable is [DataType] [VariableName];
For Example I want to create a String member variable of name "MyName", then the code will be. String MyName="";
Abobaker Alkandery
655 PointsThanks for helping
they ask me to make it "public" String, Task: (Now add a String member variable named mTitle. Make it public)
so I tried your answer, but it's not work :(
Ayaz Parwaiz
Courses Plus Student 2,284 PointsDear Aboobaker, You are doing wrong code. Correct code is
public String mTitle;
Abobaker Alkandery
655 PointsAbobaker Alkandery
655 PointsAny help please