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

mustafa attaie
mustafa attaie
8,068 Points

how to create an object using a class created in another file?

I'm stuck on a challenge that i don't understand to well. I just grasped the idea of creating a public and private class. Now that i've created it how do i use it the way i should in this code challenge? Can someone please explain the right way to Call a class in this challenge task?

public class Example {

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

1 Answer

Jacob Bergdahl
Jacob Bergdahl
29,118 Points

You're on the right track! Remember to give the variable a name! For example: goKart. So that's GoKart goKart (the datatype followed by the name). Next, you can't simply pass in the word color, because Java doesn't know what that is. You must pass in an actual colour! I'm not going to give you the straight answer, because I want you to go back and watch the last video again :) You'll learn much more that way :)