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

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