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!

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

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 :)