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

I have a problem i don't understand in the Challange task "PictureBook.java" part two.

The task is " Now add a String member variable named mTitle. Make it public."

the code i have writen is the same as i have in my project when folowing the previous videos.

public class PictureBook { public String mTitle() { } }

i then get a syntax error "./PictureBook.java:3: error: missing return statement } ^ 1 error"

But it do not understand the error, i have the "}" in the code ?

when i look at the similar code i have in my project it exactly the same just with different String name.

Can anyone help me understand this?

PictureBook.java
public class PictureBook {
  public String mTitle() {

  }
}

try switching it to wumbo.

@Brian Wassel thanks for your reply, the course have not went throug what wumbo is, would you care to explain how and why i should use it?

1 Answer

The challenge is asking you to declare a member variable and you're declaring a method. Get rid of the parenthesis and curly brace and you'll have the variable definition. Right now you're declaring a method that returns a String which is why it's complaining about a missing return statement.