Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

"this" and "super"

 
Rajiv Goyal
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 456
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1090
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rajiv
There is no this in a static reference, for example the main() method.
[ August 08, 2003: Message edited by: Anupam Sinha ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic