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 do i do this

how do i do this

Example.java
public class Example {

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


    }
}

2 Answers

Grigorij Schleifer
Grigorij Schleifer
10,365 Points

Hey Brian,

for creating a new object you need a class. This class is a blueprint that stores parameters (something an object of that class knows) and methods (behaviors of the object of that class).

To create an object you should write the name of the class:

GoKart

then the name of the object (use your imagination, but follow conventions (s. internet))

goKartObject

and then:

= new GoKart();

but donΒ΄t forget to give your new created object a parameter. In the challenge it is a String representation of color, for Examnple "red"

So the line should look like this

GoKart goKartObject = new GoKart("red");

Hope it helps :)

Grigorij

Hey Brian,

With Grigorij's answer, you may also want to review the video on constructors.