| Author |
this and super
|
Raj chiru
Ranch Hand
Joined: Aug 12, 2008
Posts: 141
|
|
Hi....
can I use this and super in static methods?
|
 |
Balu Sadhasivam
Ranch Hand
Joined: Jan 01, 2009
Posts: 874
|
|
No and No
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56549
|
|
|
As they refer to instances, and, by definition, there are no instances associate with static methods, how could that make any sense?
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Raj chiru
Ranch Hand
Joined: Aug 12, 2008
Posts: 141
|
|
Hi balu
Thanks for your reply.
can you tell me the reason?but what about in instance methods?
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56549
|
|
|
I just told you the reason.
|
 |
Balu Sadhasivam
Ranch Hand
Joined: Jan 01, 2009
Posts: 874
|
|
Bear has explained why not in static.
instance methods can use both super and this , as both keywords meant to associated with instance.
"this" refers to current object.
"super" is used to call a method on the base class that has been overridden by Child.
|
 |
Raj chiru
Ranch Hand
Joined: Aug 12, 2008
Posts: 141
|
|
Hi.. Bear
Thanks for your reply
|
 |
 |
|
|
subject: this and super
|
|
|