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 trialtrevoryusi
Courses Plus Student 351 Pointsproblem with symbol
please look at row 7
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
Full Stack JavaScript Techdegree Graduate 35,467 PointsHey 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.