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 trial

Java Java Objects (Retired) Meet Objects Creating New Objects

Hillary J
Hillary J
757 Points

Actual 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?

Example.java
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

Your 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
Carlos Federico Puebla Larregle
21,073 Points

With 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.