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

how to creat objects in Java objects

Please create a new GoKart object. As you know it takes a single parameter, color.

Example.java
public class Example {

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



    }
}

1 Answer

Hey bro,

You should've watched the video again if you're not sure.

GoKart Parameter = new GoKart();

You misunderstood the idea of a "parameter" here. The parameter is used by the "constructor" which looks like a method called alike the class itself (here -> GoKart() ) To use a parameter actually you need to throw it into the () of the GoKart constructor.

GoKart newKart = new GoKart("blue");

In this example right above I passed a parameter (as the String "blue") into the GoKart Constructor. That's what the author was meaning by parameter.

You just changed the object's name to "parameter" - which is valid - but not the best solution for a GoKart object :)

Hope I could've helped you

After you changed the Challenge and it worked out well - please watch the video again. I always watch such videos 2-3 times until I really realize every step taken there.