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 trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Abobaker Alkandery](https://uploads.teamtreehouse.com/production/profile-photos/4833492/micro_2370.jpg)
Abobaker 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](https://secure.gravatar.com/avatar/ed792ef7584207802b7556057724fe13?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
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](https://uploads.teamtreehouse.com/production/profile-photos/4833492/micro_2370.jpg)
Abobaker Alkandery
655 PointsIt's work :)
thanks a lot coach Ben
![Ismael Soumahoro](https://secure.gravatar.com/avatar/67fb8321bfe38efbcb45d97600981d8e?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Ismael Soumahoro
6,410 Pointswhat do you mean with just a semicolon?
![Ben Jakuben](https://secure.gravatar.com/avatar/ed792ef7584207802b7556057724fe13?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
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](https://uploads.teamtreehouse.com/production/profile-photos/4859262/micro_haha.jpg)
Hendy Budhigraha
17,328 PointsMaybe you can try the following code:
public String mTitle;
![Abobaker Alkandery](https://uploads.teamtreehouse.com/production/profile-photos/4833492/micro_2370.jpg)
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](https://secure.gravatar.com/avatar/38e743029215d628a10ef388773e9785?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
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](https://uploads.teamtreehouse.com/production/profile-photos/4833492/micro_2370.jpg)
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](https://secure.gravatar.com/avatar/38e743029215d628a10ef388773e9785?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
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