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 trialAusten Ham
530 Pointshow do i Add the proper access level modifier to the color field to ensure it's privacy.
plz help
public class GoKart {
private String mColor = "red";
public String getColor() {
return mColor;
}
}
3 Answers
Jason Anello
Courses Plus Student 94,610 PointsHi 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.
Aiden Rosalez
360 PointsThanks that helped
issak servin
409 Pointspublic class GoKart { private String mColor = "red";
public String mColor("red") { return mColor; } }
i need help ;0
Aiden Rosalez
360 PointsAiden Rosalez
360 PointsWhere do u change it at couse i can not find out how
Jason Anello
Courses Plus Student 94,610 PointsJason Anello
Courses Plus Student 94,610 PointsHi Aiden,
Check the code posted in the question. It shows where the
private
modifier goes.