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 triallinda wu
3,016 PointsProblem with constructor exercise
class GoKart { private String color;
public String getColor() { return color; }
public String GoKart(String color) {
}
}
class GoKart {
private String color;
public String getColor() {
return color;
}
public String GoKart(String color) {
}
}
2 Answers
Steve Hunter
57,712 PointsHi Linda,
Constructors don't have a verbose return value, i.e. they are silent as to what they return. They are named the same as the class and can take parameters, as you have done well. So, remove the String
keyword between public
and GoKart
and you're good to go.
Steve.
linda wu
3,016 PointsThank you, it really helped! I didn't see the difference between define a constructor vs method in the tutorial.
Steve Hunter
57,712 PointsNo problem!