Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Java Objects (Retired) Meet Objects Creating New Objects

problem with symbol

please look at row 7

Example.java
public class Example { 
  private String mKart = new String ("red");
  public String getColor() {  
    return mKart; }
  public static void main(String[] args)  {  
        System.out.println("We are going to create a GoKart");
      System.out.printf("The color is %s.", getColor);
                        };
}

1 Answer

Rob Bridges
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Rob Bridges
Full Stack JavaScript Techdegree Graduate 35,467 Points

Hey there,

I think the trouble with this first is that you are creating a new method for getColor, this is already defined in the GoKart class, so there's no need to recreate it.

It looks like you also created the kart as a String object, it's really part of the GoKart object.

So the creation code would look something like this

GoKart blueKart = new GoKart("blue");

This would create a new GoKart object with the color blue, in the next step it would ask me to get the color, thankfully. There's an method in the GoKart class for that.

In the next object it would be asking us to print a formatted String from the System class using the getColor() method.

This would look like

System.out.printf("The color is %s", blueKart.getColor());

all together this challenge code should look similar to

public class Example {

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

Though of course you can change the color to anything you want.

Thanks let me know if this doesn't help.