This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes  this in method parameter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark " this in method parameter" Watch " this in method parameter" New topic
Author

this in method parameter

ashok ks
Ranch Hand

Joined: Oct 31, 2003
Posts: 55
what is the meaning of 'this' in the following hai(this) here hai is the methood name.
Adam Altmann
Greenhorn

Joined: Nov 15, 2003
Posts: 21
I believe it's just passing whatever object called the method, into that method as it's argument. So, if the Hai method looks like:
public void Hai (Object ob){
//Do some nifty stuff to ob
}
Then when you call Hai(this) from <whateverObject>, then (a copy of the referece to) <whateverObject> is passed in to Hai (which is then used as "ob" inside the method.) Again, I believe this is correct, but I'm not 100%.


SCJP 1.4
Mark Vedder
Ranch Hand

Joined: Dec 17, 2003
Posts: 624

Originally posted by Adam Altmann:
Again, I believe this is correct, but I'm not 100%.

You are correct
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: this in method parameter
 
Similar Threads
Only fun forwards for fun ...
Mislead to believe that the page is completed without any errors
spring-jdbc doubt
Guess the pass percentage....
i have passed java 5 with 98%