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

Java Spring Basics Modeling, Storing, and Presenting Data Create a POJO

Treehouse online IDE keeps complaining about getter for 'id' is missing, but I am following the bean naming conventions?

I have checked the code over and over and I cannot find the mistake, which probably is right there in my face.

com/teamtreehouse/contactmgr/model/Contact.java
package com.teamtreehouse.contactmgr.model;

public class Contact {
  public int id;
  public String firstName;
  public String lastName;
  public String email;

  public int getId() {
    return this.id;
  }

  public void setId(int id) {
    this.id = id;
  }

  public void setFirstName(String firstName) {
    this.firstName = firstName;
  }

  public String getFirstName() {
    return this.firstName;
  }

  public void setLastName(String lastName) {
    this.lastName = lastName;
  }

  public String getLastName() {
    return this.lastName;
  }

  public void setEmail(String email) {
    this.email = email;
  }

  public String getEmail() {
    return this.email;
  }

}

3 Answers

Seth Kroger
Seth Kroger
56,414 Points

Well this is an odd one... I've tried out a couple variations and it seems the challenge checker is being picky about the use of "this." in the getters. It's not something that should make a difference normally, but it seems to be checking for a specific syntax (ie. the getters/setters generated by IntelliJ) and not just whether there is a working getter. If you remove the "this." from the return statements in all four getters it will pass the challenge. But perhaps it should accept "this." as well?

Tagging Chris Ramacciotti

Yep that was the issue. However, setting aside the fact that I was declaring the properties 'public' when they should have been 'private' using 'this' to reference to instance variables is valid java code. I spent a lot of time on that exercise because of it :(.

Thanks.

Chris Ramacciotti
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Chris Ramacciotti
Treehouse Guest Teacher

Hi Francisco,

I've updated the challenge so that it accepts the valid answer you were attempting. I apologize for not getting to this before you spent time on it. But, thank you for posting your concerns here in the community because it's exactly what helps us to continually improve!