Two Laptop Bag
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 OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "The Watch "The New topic

The 'this' keyword

Alan Smith
Ranch Hand

Joined: Oct 19, 2011
Posts: 185

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;'?

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..
I agree. Here's the link:
subject: The 'this' keyword
It's not a secret anymore!