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 trialkalyada leosrisook
Courses Plus Student 17,855 PointsI'm stuck in this last Gokart challenge. someone please help!
Hi, I've been stuck in this last challenge where you need to apply the getColor method. When I use the method I got an error saying that:
'method getColor in class GoKart cannot be applied to given types; System.out.printf("The go kart color is %s\n", gokart.getColor("red"));'
What does this mean? Can anyone explain? Thank you in advance...
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 go kart color is %s\n", gokart.getColor("red"));
}
}
2 Answers
Hendrik Heim
1,012 Pointspublic class GoKart {
private String _color;
public GoKart(String color){
_color = color;
}
public String getColor(){
return _color;
}
}
is your GoKart class "equal" to this?
Notice, that you your _color field ist String, so is your Constructor Parameter and your method should also return a String.
kalyada leosrisook
Courses Plus Student 17,855 PointsYeah, mine kinda look like your, except that I use ' mColor instead of _color. Is that the problem? what does _ means?
Hendrik Heim
1,012 Points_color / mColor is just a variable name. So it is irrelevant.
Show me your GoKart class to identify the problem
Hendrik Heim
1,012 PointsHendrik Heim
1,012 PointsCan you show me your getColor implementation?