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 Java Objects Meet Objects Access Modifiers

how do i Add the proper access level modifier to the color field to ensure it's privacy.

plz help

GoKart.java
public class GoKart {
  private String mColor = "red";

  public String getColor() {
    return mColor;
  }
}

3 Answers

Hi Austen,

You only needed to add the access modifier private.

You shouldn't change the name of the field. It was color and you changed it to mColor.

Also, the challenge didn't ask for a getter but it might still pass with it in there.

Where do u change it at couse i can not find out how

Hi Aiden,

Check the code posted in the question. It shows where the private modifier goes.

Thanks that helped

public class GoKart { private String mColor = "red";

public String mColor("red") { return mColor; } }

i need help ;0