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 trialYusuf Akviran
2,668 PointsWhy use "m" before the color? I didn't understand this.
Thanks for helping!
public class GoKart{
public String mColor = "red";
}
1 Answer
Luke Glazebrook
13,564 PointsHi Yusuf!
We do this because the color is a Member Variable
of a car and all member variables are prefixed with 'm'. If you need any more help with this then feel free to ask!
Jacob Bergdahl
29,119 PointsJacob Bergdahl
29,119 PointsTo add on to this comment; the reason why we even give member variables a prefix (because it is of course syntactically possible to create a member variable without the prefix!) is so that you can easily distinguish it in your code, and also because typing "m" in your code will show you all your member variables, after which you can select one and use auto-complete. This means that you won't have to scroll up every time you want to remind yourself of what member variables you have, and that you can easily see in your code if a variable is a member variable or not!