Get the tools you need to learn Java skills fast!
Video tutorials, eBooks, hands-on lab exercises, sample code.
Get started
The moose likes Java in General and the fly likes The 'this' keyword Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "The Watch "The New topic
Author

The 'this' keyword

Alan Smith
Ranch Hand

Joined: Oct 19, 2011
Posts: 183

Hi all,

I just came across this method in a piece of code I am maintaining:



I regards to the 'this' reference... I understand that 'this.BACKING_LIST' is a reference to this classes field called BACKING_LIST. What I don't understand is the 'return this' statement. What does 'this' refer to here? Does it refer to the BACKING_LIST that was referenced on the previous line; in other words could that line be re written as 'return this.BACKING_LIST;'?

Thanks,
Alan
Yogesh Gnanapraksam
Ranch Hand

Joined: Dec 17, 2009
Posts: 133
this is a reference to the current object


More details here

Just try printing 'this' to the console..
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: The 'this' keyword