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

I don't understand "Please create a new GoKart object. As you know it takes a single parameter, color"? Please explain.

I am having trouble understanding "Please create a new GoKart object. As you know it takes a single parameter, color."? I tried some code but it's not correct. Please help. I don't know what code or where to place my code.

public class Example {

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

1 Answer

Hi Mark,

I guess this challenge continues on from either a previous one or from the course itself. I don't know as I've done neither.

Essentially, it is relying on you knowing that the constructor for the GoKart class creates a nrw instance of a GoKart and requires one parameter which is a string representation of a colour.

So, the line of code that does this would look something like:

GoKart redKart = new GoKart("Red");

That declares a variable of type GoKart before the equals sign, allocating a GoKart-sized chunk of memory for that purpose then, after the equals sign, initializes the variable by executing the constructor which then fills the chunk of memory with the instance of a GoKart which is "Red".

That code should be placed after the println statement in the challenge.

I hope that makes sense.