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

Android

Having trouble with a challenge

challenge question: Now add a String member variable named mTitle. Make it public.

Code I tried but doesn't work:

public class PictureBook {

public String mTitle (){ } }

4 Answers

Maybe something like: public String mTitle = new String();

That worked thanks

you created a method, not a variable.

methods have (){ } after them, variables declarations just end in a semicolon.

all you need to do is declare the variable:

public class PictureBook {

public String mTitle;

}

it doesnt tell you to assign it anything which is why assumed it wants just the declaration.

Doing this didn't work for me but doing what Mark Josephsen suggested did work. Maybe something is broke in the challenge and its looking for a variable instead?

just tried it again and it worked using

public class PictureBook {

public String mTitle;

}

There's no return type. Is it void?

Wait a second, that's a method, not a variable.