If I create a class that looks like this:
public class TagManager {
private final Context mCtx;
public TagManager (Context ctx) {
this.mCtx = ctx;
}
}
What is the difference between using
this.mCtx = ctx;
versus
mCtx = ctx;
As far as I can tell they both do the same thing but I can’t find any discussion of it.
For sure it’s the same. It’s just a matter of CodeStyle – it’s up to you to select what you like more.
The only reasonable case to make this.* is when your argument and member variable have the same name. For example
However, Android Code Style tells us to use m*** prefix for member variables, so this situation should rare happen in your classes.
Good luck