In Java, this is a placeholder used within a class definition to represent the object that the instance method was invoked on. If you think about it, the person who wrote the class implementation has NO WAY of knowing what identifiers a user might come up with when using a class, and if the user has instantiated more than one object of the same class, the implementer would have no way of talking about the current object without this! In such a situation, this may be seen followed by a dot (.). Then, it refers to the object that received the message that caused that instance method to be invoked, and may be used to gain access to one of the receiver object's instance variables. (For example, see the distanceTo( int x, int y ) or distanceTo( int x, int y ) method in our Point class, linked below for sections 10 and 14, respectively.) "this" may only be used in such a way in INSTANCE methods, not in class methods. This (:-)) rule should make sense because there is no object involved when a class method is invoked.
If this is seen in a constructor followed by a "(", it is a reference to another constructor within this same class definition. If used, it must be the FIRST line of that constructor.
For examples of the use of this, see the implementation of the Point class for your particular section from http://www.cs.rit.edu/~ncs/Courses/cs1/Point/. It contains a heavily annotated version of the Point class which we wrote in your class.
That's a really interesting question. I believe this has to do with the fact that when we instantiate a variable by saying
Point p = new Point();there is actually some stuff going on that isn't seen in the implementation of the constructor, i.e., memory space is being allocated to store the state of the Point (e.g., the instance variables). So, if we were to invoke another constructor from within another one by using its "real name", I could imagine that we could run into trouble with memory being allocated twice! I suspect that's why we have this special name to use. Its syntax likely says: "Don't allocate more memory; just execute the statements in the implementation."
I am linking the Scope directory here so that you can download Scope.java, ScopeTest.java, and the output. I would suggest that you try running the programs and see if you understand why the output is what it is. You might also try changing the Scope.java program a bit and see how your changes affect the output.
Scope in this sense is just a class I created to show you more about the concept of scope. The concept of scope has to do with which identifiers are known where and what name we have to use to access an individual identifier. A related concept is the lifetime of an identifier, i.e., how long a particular identifier is in existence. For example, variables that are local to a method are only "alive" for as long as that method is executing.
So, if you create an object and have access to its instance variables like we did in the Scope example (because the instance variables a and b were public), you are able to access them from your program by specifying the object_name.instance_variable_name. In our case, we had an instantiated Scope object called s. All instantiated Scope objects have instance variables called a and b. To access them directly in our ScopeTest program, we must refer to them as s.a and s.b.
I hope you recognize that the code in both Scope and ScopeTest is not really good code. I purposefully did not use meaningful variable names to demonstate this concept. If you can trace and understand (bad) code like this, you will be a very valuable employee indeed! :-)