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 trialissak servin
409 PointsLet's make the color field on our GoKart inaccessible to other classes.
public class GoKart { private String mColor = "red";
public String mColor("red") { return mColor; } }
public class GoKart {
private String mColor = "red";
public String mColor("red") {
return mColor;
}
}
1 Answer
Joseph Wasden
20,407 Pointsgiven the code challenge, you've done too much. You do not need the method you are trying to add after the member field. also, there is no need to rename the member field with the lower case m in front of it.
See the code below.
class GoKart {
private String color = "red"; //<-- notice no 'm' in front of variable name
//The below code is unnecesary to the task of the code challenge
// public String mColor("red") {
// return mColor;
// }
}