So I’m learning Java currently and I just learned about ‘this’ but I don’t quite get what the point of it is..
From what I read… it’s used by coders in order to not confuse the instance variables with their methods’ parameter variables and hence they use ‘this’
I also read that it is to take a reference of the instance variable.
However what I don’t get it that can’t you just either use different parameter variable names in order to avoid the confusion? And why can’t I just write the instance variables name directly instead of using ‘this’, like it still works that way…?
I also attached a picture on what I mean. In the picture, there is already a different parameter variable name, so there’s no confusion in that, and when it comes to initializing the instance variable, can’t I just do
name = theName;
Or
return name;
Instead of whatever they have in the picture?