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 trialHillary J
757 PointsActual and formal argument lists differ in length
Can't figure out what's wrong with this code. It says to create a GoKart object from the Go Kart class. Then it mentions something about the color parameter, but I'm not sure how to plug that in. It won't accept the getColor from the other GoKart.java file. What am I doing wrong?
public class Example {
public static void main(String[] args) {
System.out.println("We are going to create a GoKart");
GoKart kart = new GoKart();
}
}
2 Answers
jcorum
71,830 PointsYour kart looks great, except that it needs a formal parameter, the color. That's why you were getting that message. It wanted 1 parameter. You were sending none. Then you just need to print it out:
GoKart kart = new GoKart("purple");
System.out.printf("%s", kart.getColor());
Carlos Federico Puebla Larregle
21,074 PointsWith the creation of the constructor (in the last code challenge) we specified that an instance of the class "GoKart" needs to be instantiated with an String argument to be created. Like this:
GoKart kart = new GoKart("blue");
The String color goes in between those parenthesis.
I hope that helps a little bit.