So I have searched a lot -and by "a lot" I am mean it-, both in this website and in other ones, to realize what the keyword this
does in java.
I am following tutorials these days to develop a game for Android. In these tutorials, the uploader puts "this" as a parameter but he doesn't explain why he does it.
What I know so far:
- It can be used as a parameter (this is the part I get most confused)
- It can be put like this
Fish.this
to refer to an outer class (not so sure about this one) - It can be used to refer to refer to outer variables (worst definition ever, I know) like this:
public class Humans{
int name; //aka name1 public Humans(int name){ //aka name2 this.name = name; //the name1 = name2 }
I'd like to have an in depth explanation of that keyword since I find it really confusing and, at the same time, it prevents me from moving on with the tutorials (please don't bother answering if your response is going to be brief, I like to have things clear in my mind because I get confused easily, especially in programming). I am stuck and your help would be much appreciated!