Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Mark Cusack
3,909 PointsChallenge question help please.
I am stuck on this question = Please create a new GoKart object. As you know it takes a single parameter, color.
I might not be understanding the question and what it is asking of me. I have attached my code so far.
public class Example {
public static void main(String[] args) {
System.out.println("We are going to create a GoKart");
GoKart gokart = new color();
}
}
4 Answers

Stephen Bone
12,359 PointsHi Mark
So you got the first bit correct creating a variable of type GoKart with GoKart goKart = and it's then at this point that we use the constructor (that's in the GoKart class) to actually create a GoKart object. In this case the constructor expects a colour value to be passed into it like new GoKart("Orange").
So the whole code should be:
GoKart goKart = new GoKart("pink");
Hope it helps!
Stephen

Robert Richey
Courses Plus Student 16,352 PointsHi Mark,
At about 2:51 in the Constructors video, Craig shows a new object being constructed from a class and passes in an argument to that constructor - like you need to do for this challenge.

jacobproffer
24,603 PointsHey Mark,
I'm not 100% sure on this, as I haven't taken this course. But are you using an instantiable class for your GoKart object?
If so, when creating a new object, the mark-up should look similar to this:
GoKart gokart;
gokart = new GoKart();

MUZ140564 Kudakwashe Jena
4,895 Pointspublic class Example {
public static void main(String[] args) {
System.out.println("We are going to create a GoKart");
GoKart goKart = new GoKart ("red");
System.out.printf("The GoKart is %s",redKart.getColor() ); } }
where am i going wrong? I keep getting an error message.
Mark Cusack
3,909 PointsMark Cusack
3,909 PointsThank Stephen that did work, way must I use - new GoKart ("pink)
Stephen Bone
12,359 PointsStephen Bone
12,359 PointsGreat! Glad it helped.
Java is case sensitive so GoKart and goKart aren't the same. Classes (as oppose to variables) should always start a capital letter and a constructor must use the same name as the class (I believe).
So here we are calling the constructor of the GoKart class.
I'm not really sure that clears anything up but hopefully it made at least some sense :)