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 trialMichel Bourgeois
731 PointsAdd a getter method that exposes the color field.
I have been trying to add a simple getter method and return a color but does not work????? any ideas???? i m almost sure that the code is good but ????
class GoKart {
private String color = "red";
public String getColor();
{
return color;
}
}
5 Answers
Michel Bourgeois
731 PointsGot it!!!!!! it was my semi colon that i erase and now it is working
Craig Dennis
Treehouse TeacherThanks for the update!
Eugene Cidro
1,546 PointsThanks.. i figured it out too... semi colon after the open and close parenthesis..
Jamal Shiekh
6,440 PointsThe Answer is:
class GoKart { private String color = "red";
public String getColor() { return color; } }
Muhammad Asif
Courses Plus Student 557 Pointsclass GoKart { private String color = "red";
public String getColor() { return color; } }
Moinuddin khan Mohammad
Courses Plus Student 1,863 PointsI am still having trouble executing the code my code is as follows, can anyone please help me out here.
class GoKart{ private String color ="red"; public String getcolor() { return color; } }
Karly Lamm
7,865 PointsThis code works besides the ; used after getColor()
Nimish Chandola
4,334 PointsNimish Chandola
4,334 Pointsi am having a problem in this code. There is error Did you forget to return color?