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

Robert Walsh
Robert Walsh
802 Points

confused on how to create the object...any help would be great?

confused on placement and how to create this

Example.java
public class Example {

    public static void main(String[] args) {
        System.out.println("We are going to create a GoKart");
    }
}
Robert Walsh
Robert Walsh
802 Points

I need to create the object GoKart

2 Answers

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Robert;

This redirects the conversation from the post here to this forum thread.

Prompting Code:

public class Example {

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

So, your question in the other post thread was related to where you put the code for this challenge, correct? Specifically the other student had another line of code after public class Example { that was attempting to make a class inside the Example class, or a nested class. That is not necessary for this challenge at all.

You want to create the new GoKart object after the statement that you are going to create a GoKart, so it would look something like:

public class Example {

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

Post back if you are still stuck.

Ken

Robert Walsh
Robert Walsh
802 Points

Thank you, this worked perfectly.

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Robert;

Welcome to Treehouse!

I posted an answer to this question here. Have a look and post back with any additional questions.

Happy coding,

Ken

Robert Walsh
Robert Walsh
802 Points

thank you very much for your quick response

Ken Alger
Ken Alger
Treehouse Teacher

Robert;

Any further questions or was the previous post sufficient in explaining things?

Ken

Robert Walsh
Robert Walsh
802 Points

still confused when i place your code into the challenge it returns an error