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 trialPeter Price
4,007 PointsPrint out using System.out.printf the color of the new object, using the getColor method.
Does anyone know what is wrong with my code?
public class Example {
public String mColor;
public Example(String color){
mColor = color;
public String getColor(){
return mColor
}
public static void main(String[] args) {
System.out.println("We are going to create a GoKart");
GoKart goKart = new GoKart("red");
System.out.printf("The GoKart color is %s\n", goKart.getColor());
}
}
1 Answer
Rob Bridges
Full Stack JavaScript Techdegree Graduate 35,467 PointsHey Peter,
You are giving yourself more work than than you have to for this challenge, we don't need to declare a variable for Color, the testing code already has it available.
Really you have the code you need to pass the challenge, however cut off the top part and leave yourself with.
public class Example {
public static void main(String[] args) {
System.out.println("We are going to create a GoKart");
GoKart goKart = new GoKart("red");
System.out.printf("The GoKart color is %s \n", goKart.getColor());
}
}
That will pass the challenge.
Thanks shoot back if you're still having trouble.
Peter Price
4,007 PointsThank you very much, that shot me straight through!!
Rob Bridges
Full Stack JavaScript Techdegree Graduate 35,467 PointsGlad to hear it!
Peter Price
4,007 PointsPeter Price
4,007 PointsIt says in the output.html: System.out.printf("The result from the method is %s", goKart.getGoKart()); With an arrow under the "." after goKart