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 Build a Simple Android App (2014) Improving Our Code Creating a Class

Claudio Chandia
Claudio Chandia
357 Points

Can someone helpme?

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

Bummer! There is a compiler error. Please click on preview to view your syntax errors! Preview Get Help Recheck work PictureBook.java

1 public class PictureBook{ 2 3 public String mTitle() { 4 5 } 6 7}

PictureBook.java
public class PictureBook{

  public String mTitle() {

  }

}
Claudio Chandia
Claudio Chandia
357 Points

I DONT UNDERSTAND WHAT THE PROBLEM IS. DO YOU?

3 Answers

Shazad Kazi
Shazad Kazi
10,758 Points

Here's what I got and it worked fine. Let me know if it helps.

public class PictureBook{
public String mTitle;
}
Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Claudio;

Welcome to Treehouse!

Your code above is not defining a variable but is instead creating a function. To define a public String variable you just need to follow the format of:

public String variableName;

Post back if you are still stuck.

Ken

T K
T K
1,875 Points

./PictureBook.java:2: error: class, interface, or enum expected public String mTitle; ^ 1 error

Its asking for a return value... ??

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

Bummer! There is a compiler error. Please click on preview to view your syntax errors! Preview Get Help Recheck work PictureBook.java