java programming language [closed]
what is 'this' keyword and what's its functions?
The this
keyword refers to the current object in the context in which the keyword appears.
Here's an article with more: http://www.quirksmode.org/js/this.html
In Java this
refers to the object you are currently in. See http://download.oracle.com/javase/tutorial/java/javaOO/thiskey.html
In JavaScript that is true as well, but in a function it can mean the "owner" of a function or the global object (ie window
). See http://www.quirksmode.org/js/this.html
The this refers as to the object you are currently in. For example, if your object has a method called doSomething(), you could call the method , from another method in your class by doing:
this.doSomething();
Hope this helps.
this
refers to the current object, so its methods are those defined by the class that the current object is an instance of.
精彩评论