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 trialBrad Smeltzer
1,018 PointsI can't find my error in creating the constructor GoKart
Here's my attempt from the challenge:
public class GoKart { private String mColor = "red";
public String getColor() { return mColor; } // here's where I'm attempting to create the constructor, but I get an error.
public GoKart(String color); { mColor = color; } }
Can anyone see anything obvious why this doesn't work? Thanks!
Brad
public class GoKart {
private String mColor = "red";
public String getColor() {
return mColor;
}
public GoKart(String color); {
mColor = color;
}
}
1 Answer
Rick Buffington
8,146 PointsYou are spot on, however you have a small typo at the end of the constructor name/parameter declaration. There is no need for a semicolon at the end.
public GoKart(String color); { // <-- Get rid of the semi-colon
SHOULD BE:
public GoKart(String color) {
Brad Smeltzer
1,018 PointsBrad Smeltzer
1,018 PointsThanks, Rick, for taking the time. I was getting extremely bugged by this challenge, but to find it was only the unnecessary semicolon was a great relief! I went back and pushed on through the rest of that set of challenges. I greatly appreciate it!