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 trialDavid Geoffry
444 PointsNeed help with putting in the return method plz have the getter but not the return
idk
class GoKart {
private String color = "red";
public String getColor();
return color;
}
4 Answers
Gabe Olesen
1,606 PointsIf I'm not mistaken you'd need to do the following:
class GoKart { // open GoKart class
private String color = "red";
public String getColor() { // open getColor method
return color;
} //close getColor method
} // close GoKart class
Because you're creating a method, in this case "getColor()" you need to return the variable "color" inside of the "getColor()" scope thus {} are used.
Hope this helped!
Gabe
MODERATOR EDIT: Added Markdown to the code so that it is readable in the Community Response. Please refer to the Markdown Cheatsheet when posting code in the Community for the proper ways, so that it is readable.
james south
Front End Web Development Techdegree Graduate 33,271 Pointswatch what he does in the videos, every method looks like this (at least as to the {}):
public String myFunction(){
[method body]
return [String]
}
you have the right code you just need to add the {} as in my example and in the videos.
james south
Front End Web Development Techdegree Graduate 33,271 Pointsyou are missing curly braces {}. public String myFunc() { body of function }
David Geoffry
444 Pointscould you explain it differently or something I still don't get it sorry :P