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 trialMatthew Kramer
619 PointsWhy do the field and argument values need to be the same? I am already confused on the subject! Color VS color? WTF
Make sure the color you pass to Color is the same as the Value set by This.Color? What?????????????
class GoKart {
private String Color = "red";
public GoKart(String color) {
This.color = Color
}
public String getColor() {
return color;
}
}
1 Answer
Steven Parker
231,275 PointsI think one point of this exercise is to be sure that you know how to differentiate a field and an argument if they have the same name. In actual practice, you would quite possibly choose a different name for one of them.
Notice that for this exercise, both names should be "color" (all lower case).
Also, the keyword "this" should always be all lower case.
Matthew Kramer
619 PointsMatthew Kramer
619 PointsNot once did I see any mention to "This.color" needing to be lowercase. not even in the Bummer message. I was literally going insane trying to figure out why color was not equal to color. and color wasnt even the issue it was "this".
So infuriating... I thought I knew what was happening and now after this I am not sure anymore. Ugh.
Sorry.