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 trialNathan Huls
5,709 PointsFirst, define a public constructor that expects a String argument named color. (Don't worry about adding any code inside
The hint is telling me to make sure my constructor is the same name as the class. I am not seeing the issue here.
class GoKart {
private String color = "red";
public String GoKart() {
}
}
2 Answers
Steve Hunter
57,712 PointsHi Nathan,
It wants a String argument; you have it returning a String.
Arguments go inside the brackets. The constructor returns nothing but is silent, so there's no need to put the void
keyword there. Something like;
public GoKart(String color){
// make a GoKart!
}
I hope that helps,
Steve.
Steven Couture
2,106 PointsAs Mr. Hunter said before, you have it returning a string but what you should be doing is having it take a string argument. F.Y.I. constructors don't return anything, they are meant to initialize class members and/or take arguments.
Nathan Huls
5,709 PointsNathan Huls
5,709 PointsThanks Steve, that absolutely helped.