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 Meet Objects Constructors

Julie Austin
Julie Austin
1,322 Points

Confused about this. or using m

So this.characterName or mCharacterName is used to differentiate a private String from a public string with the same name? what if you have a code block with multiple private and public strings? I'm not clear on this concept.

1 Answer

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Julie;

Great question. The m prefix vs this. is a naming convention to handle member variables. The use of which will likely depend on your code base. The m prefix was very popular in Android development for a while, but seems to have fallen out of favor towards using this. It really has more to do with scope than anything else as to which variable is being referred to. Mr. Hampton provides some additional information in his post here.

I hope that helps, but post back if you're still stuck.

Best wishes,
Ken W. Alger