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 trialZamy Khan
Courses Plus Student 953 PointsChallenge 2 task 2 'Now change the color field to be private by adding the access level modifier.'
i have attempted the question many times with this code but i always comes with syntax errors.
public class GoKart { public String mColor = "red";
public String getColor() {
return mColor; }
}
public class GoKart { private String mColor = "red";
public getColor() { return mColor; }
public setColor(String color){ mColor = color;}
3 Answers
Ricky Sparks
22,249 Pointspublic class GoKart { private String mColor = "red"; public String getColor() { return mColor; } }
William Dalessi
1,266 PointsExamples and answers to the exercises would be helpful, and save everyone a lot of time!
Craig Dennis
Treehouse TeacherThe instructions are asking just for the color field to be marked private (instead of public).
Other code is looking pretty good, you just got ahead of the challenge ;)
Hope it helps!
Ricky Sparks
22,249 PointsRicky Sparks
22,249 Pointsadd String to getColor and erase the last line of code it is not needed public setColor(String color){ mColor = color;}