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 trial1 Answer
Grigorij Schleifer
10,365 PointsMahvish,
to create an object in Java you need to use the word "new", the name of the class (the object is created of) and parenthesis with arguments (if the class has defined such arguments). If you look how to create a GoKart object it should look like this:
GoKart gokart = new GoKart();
// gokart is the name ob the object from the GoKart class
// it takes no arguments (parenthesiss is empty
GoKart gokart = new GoKart("Red");
// this is an object of the GoKart class too
// that takes a String argument "Red" that represents a color
Makes sense?
Greg
Ryan Ruscett
23,309 PointsRyan Ruscett
23,309 PointsNot sure what you are asking here. Can you provide some code of what you are trying to do that does not work?