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 trialNaya Willis
2,461 Pointswhat
What the hell am I doing wrong?
public class GoKart {
private String mColor;
public GoKart(String color) {
mColor = new color;
}
public String getColor() {
return mColor;
}
}
1 Answer
Kathryn Ann
10,071 PointsWhen you set mColor to the color entered for the new GoKart, you don't need to use the word "new," since you're setting a variable (rather than creating a new object).
Naya Willis
2,461 PointsNaya Willis
2,461 Pointsbut isn't constructors all about using the word new.
Kathryn Ann
10,071 PointsKathryn Ann
10,071 PointsYes, but that's not what that part of the code needs to do. If you are creating a new GoKart object, you'd say "new GoKart." However, mColor is a variable that you need to set to a value, so you do that by using "=" and the value you want to set it to.
Naya Willis
2,461 PointsNaya Willis
2,461 Pointsso how would the overall answer to the challenge look? Im not being lazy, i just want to know and study your answer because i been on this challenge for weeks now lol
Kathryn Ann
10,071 PointsKathryn Ann
10,071 PointsIf you just remove the "new" in front of "color," what you have should work!