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 Weather App (2015) Working with JSON Creating a Model Object

Ben Mair
Ben Mair
8,728 Points

POJO Getter/Setter

I am assuming I am doing something wrong.......However I am not getting any errors........But it won't let me pass.

Movie.java
public class Movie {
 private String mTitle;
 private int mYearReleased;


  public String getTitle() {
    return mTitle;
  }
  public void setTitle(String title) {
  title = mTitle;
  }
  public int getYearReleased() {
  return mYearReleased;
  }
  public void setTitle(int yearReleased) {
  yearReleased = mYearReleased;
  }
}

2 Answers

Jon Kussmann
PLUS
Jon Kussmann
Courses Plus Student 7,254 Points

Couple of errors that I can see.

You have two setTitle() methods, I think the second one you mean to be setYearReleased().

In your setters, you are attempting to assign the local variable (passed as a parameter in the respective setter) with the member variable. You should be doing the opposite. In other words, switch the two variables around the '=' signs in each of your setters.

mTitle = title;