The problem with the examples is that they show the correct use of "this", but they don't say what would happen if you didn't use "this"
I think it might help me if someone could make a statement such as:
If you want result X, then you must use "this". But if you want result Y, then don't use "this". If you want result Z, then it doesn't matter whether or not you use "this".
Therefore, I would be most grateful if someone could give me two very short pieces of code that I could run in Eclipse.
One piece of code would use "this", and the other would not. I can then use single-stepping to examine what happens with and without "this"
I would prefer if the sample code did not refer to a constructor, so that I can get the simple stuff in my mind first (if ever!)
Of course, if some kind person wants to provide *four* tiny runnable code examples (two pieces that are not for a constructor, and two pieces for a constructor), then I would be delighted. Killing 4 birds with "this" stone
'this' is simply a reference to the current object. Sometimes you explicitly need to refer to the current object, so you need to use 'this' - for example, if you have a method with an argument which has the same name as a member variable.
Note: Don't forget to check your private messages (click the link at the top left of the page).