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 trialFaisal Julaidan
13,944 PointsWhat is the 'm' at the beginning of every field name?
I see that every time the lecturer declare a new filed, he put the 'm' letter at the beginning of the field name
Why?
2 Answers
Jennifer Nordell
Treehouse TeacherHi Faisal! There are different kinds of variables including member variables defined in a class (also called fields), variables definied in a method or code block, and variables declared in the method declarations.
The instructors here teach the convention of naming member variables as starting with the lower case "m".
Here is some documentation from Oracle about variable declaration. But note that the "m" style of naming member variables is not just a convention in Java, but other languages as well.
Hope this helps!
Kourosh Raeen
23,733 PointsIt's a coding convention to start non-public, non-static field names with m to distinguish them from local variables. See more here: http://source.android.com/source/code-style.html#follow-field-naming-conventions
Faisal Julaidan
13,944 PointsFaisal Julaidan
13,944 Pointsare variables private by default ?