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 Programmer Certification (SCJP/OCPJP) and the fly likes 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 » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark ""this" and "super"" Watch ""this" and "super"" New topic
Author

"this" and "super"

Rajiv Goyal
Greenhorn

Joined: Jul 28, 2003
Posts: 25
Sometimes confused with these key words?Can you please:
a)Let me know salient features of both "separately"
b)Differnce between two
Thanks
Rajiv
Damien Howard
Ranch Hand

Joined: Apr 01, 2003
Posts: 456
Let me know salient features of both "separately"
"this" is an implicit reference to the current object. all Objects have a this reference. It can be used to pass a reference to the current object to a method in another object.
super is used to refer to the parent class of the current object. This is useful if you wish an overriding method to refer to the version of the method in the parent class.
Jessica Sant
Sheriff

Joined: Oct 17, 2001
Posts: 4313

also this() and super() play a key role in constructor.
Check out the JLS for more info and a lil example: �8.8.5 Constructor Body
Anupam Sinha
Ranch Hand

Joined: Apr 13, 2003
Posts: 1088
Hi Rajiv
There is no this in a static reference, for example the main() method.
[ August 08, 2003: Message edited by: Anupam Sinha ]
 
 
subject: "this" and "super"