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 trial

Java Java Objects (Retired) Meet Objects Privacy and Methods

Gary Byrne
Gary Byrne
16,514 Points

does naming member variable with m at beginning of it really matter?

does naming member variable with m at beginning of it really matter?

1 Answer

Richard Lu
Richard Lu
20,185 Points

Hey Gary,

The 'm' in the beginning of the member variables does not matter, it is used to make the code look more clear. Conventionally member variables are camel cased, for example:

public class AClass {
   // The first word is lowercase, and then everything other word starts with a capital letter
   public String theMemberVariable = "a String";   
}

Additionally, the 'm' prefix is helpful and a good practice because when you're outside an IDE and don't have color coding for member variables, such as when you have your code hosted on GitHub, it's easier for someone else looking at your code to better understand it.

Gary Byrne
Gary Byrne
16,514 Points

Thanks for your reply richard. Very helpful.:)