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

Please create a new GoKart object. Task 1 of 2.

public class Example {

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

Where am I going wrong?

Example.java
public class Example {

  public static void main(String[] args) {
        System.out.println("We are going to create a GoKart");
        GoKart color = new GoKart();
    }
}
Jesse Gravenor
Jesse Gravenor
27,272 Points

Hey Max,

It looks like you are naming your GoKart object "color" and not passing in any color parameters.

Hope this helps!

2 Answers

Thank you Jesse Gravenor.

Now I'm having difficulty with part 2 (I don't think there are enough hints).

'''java

public class Example {

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

'''

Any ideas?

Jesse Gravenor
Jesse Gravenor
27,272 Points

You are not calling the .getColor() on the object name that you created. This might be confusing because you named your go kart object "color", and the parameter that you passed in for the actual color value was an empty string with: = new GoKart("Color should go here").

You might consider naming the kart something like goKart or myKart and passing in a color like "red". This might help understand the object better.

Also, since the .getColor() method returns the color of the object that it is appended to, you don't need the "" in the printf line.

Let me know if what I wrote is unclear.

Thank you Jesse that's exactly was the problem with mine.