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

Help. task 2 of 2

And the prompt is : Now change the color field to be private by adding the access level modifier.

this is the code i have so far : public class GoKart { public String mColor = "red"; public String getColor(){ return mColor;}}

samuel zaffran
samuel zaffran
24,815 Points

Ok, so we want that that the color field become private. What is the color field ? It's the line : public String mColor = "red"; But right now this color field is public... You just have to change that ! Luck.

1 Answer

samuel zaffran
samuel zaffran
24,815 Points

Hi, We want that the color field being private, all you need to do is to reevaluate the access level modifier. After you created your method to get the color wich is public, you have to think how do i privatise the red color ? Can't tell you more :) Luck