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

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