This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Java in General and the fly likes The 'this' keyword Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "The Watch "The New topic
Author

The 'this' keyword

Alan Smith
Ranch Hand

Joined: Oct 19, 2011
Posts: 150

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..
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: The 'this' keyword
 
Similar Threads
about string
Implicit Narrowing Conversion
///call by reference///
static inner classes
Immutable Data structure