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 trialpriyanka shukla
3,051 PointsCan any one please tell what is mVar convention for i just forgot i have learnt it in begining of java objects .
i asked it because i am in creating database step and i need to create a lot of variables like mAuthor mTitle etc... Please tell Thank you a lot
1 Answer
Gergely Horvath
Courses Plus Student 8,207 PointsIn this convention the meaning of the lettet "m" is member. With the help of this you can ommit the "this" (it refers to the instance) prefix when you are initializing your instance variables in the constructor.
So with mVar a class with a constructor would look like this:
public class NewClass {
private final int mVar1;
private final int mVar2;
public NewClass(int var1, int var2) {
mVar1 = var1;
mVar2 = var2;
}
}
As opposed to
public class NewClass {
private final int var1;
private final int var2;
public NewClass(int var1, int var2) {
this.var1 = var1;
this.var2 = var2;
}
}
priyanka shukla
3,051 Pointspriyanka shukla
3,051 Pointsthanks