Meaningless Drivel is fun!*
The moose likes Beginning Java and the fly likes Doubt in 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 "Doubt in "this" Key word" Watch "Doubt in "this" Key word" New topic
Author

Doubt in "this" Key word

Vijay Sharma
Greenhorn

Joined: Oct 12, 2005
Posts: 17
Hi,

I just want to know what does the this keyword performs in the following code?
public void actionPerformed(ActionEvent ae)

Object src = ae.getSource();
if (src == button1)

this.doButton1Action();
}
else if (src == button2)
{
this.doButton2Action();
}

}


Cheers,<br />Vijay Sharma
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
this just means the current instance. so you are calling those methods in the instance of the ActionListener.
Vijay Sharma
Greenhorn

Joined: Oct 12, 2005
Posts: 17
Thanks Keith!!
Shaan Shar
Ranch Hand

Joined: Dec 27, 2005
Posts: 1249

You know what really difference between this and super keyword.
Actually this keyword can give you a object instance of current class. And super keyword never gives an object instance of super class. It's only use it to call method and constructer of super class.


The Best way to predict your future is to create it - Every great individual common man
 
 
subject: Doubt in "this" Key word
 
Similar Threads
iFrame src doesn't update
what are the places can we put struts.xml in eclips
weird problem
Internet Explorer, Image and XSL Problem
log4j.properties