Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Java Data Structures Getting There Class Review

Can 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
PLUS
Gergely Horvath
Courses Plus Student 8,207 Points

In 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;
    }
}

thanks