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 (Retired) Meet Objects Privacy and Methods

Alexander Nowak
Alexander Nowak
498 Points

Task 2 of 2, changing the colour field to private

I am changed the 'public' to 'private', but then its says that task 1 is failing. Could someone please help?

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

  public String getColor() {
    return mColor;


  }


}

1 Answer

Kevin Faust
Kevin Faust
15,353 Points

Hey Alexander,

all you do is change this:

public String mColor = "red";

to

private String mColor = "red";

Leave the class and method as public. That should work

Happy coding,

Kevin