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

I need a lot of help the hint are not working

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

Example.java
public static void main(String[] args) {

  public GoKart(String Color) 
  GoKart gokart = new GoKart("red");
    { 
    mColor = Color;
    }
    System.out.println("We are going to create a GoKart");
                                       }

2 Answers

Chris Howell
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Chris Howell
Python Web Development Techdegree Graduate 49,702 Points

Remove this piece of code, because the GoKart class has already been created for you even though it does't show you the tab for it.

public GoKart(String Color) 

    { 
    mColor = Color;
    }

Now you wrote the object creation piece properly, so place that underneath this line of code:

System.out.println("We are going to create a GoKart");

It should look something like this:

public class Example {

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

To pass this challenge, you can simple create the object with new GoKart("Red");

The GoKart goKart1 = is not necesarry. That is just stating the variable that you want to store the object inside of.

Albert Evangelista
Albert Evangelista
27,689 Points

You were fine with the GoKart goKart = new GoKart("whatever_color_you_want_here");
because the GoKart class was already made for you. I put this above the System.out.println.......

The next step will have you using the printf method which uses System.out.printf(%s, goKart.getColor()); I put this below the System.out.println................ %s will represent what the goKart.getColor() will get you.... well you know that right....