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.

Java Java Objects (Retired) Meet Objects Creating New Objects

Robbie Thomas
Robbie Thomas
31,093 Points

Challenge Task 1 of 2

Keep being told no on this one:

Example.java
public class Example {

    public static void main(String[] args) {
        System.out.println("We are going to create a GoKart");
        GoKart gokart = new GoKart();
}

2 Answers

When you instantiate the class GoKart you are supposed to pass in a String argument to the constructor:

GoKart goKart = new GoKart("red");

Something like that.

Any time that you instantiate an object you need to know how the constructor was setup so you know how many arguments it takes if any. If you try to instantiate an object with an incorrect number of arguments the compiler will throw an error.

Robbie Thomas
Robbie Thomas
31,093 Points

Awfully strange, doesn't really say to put a color in there. Got that and was able to finish challenge 2 (made a mistake at first by not adding a ")" to the code).

Thanks.

No problem