aspose file tools
The moose likes Beginning Java and the fly likes this and super Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "this and super " Watch "this and super " New topic
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
    
  14

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
    
  14

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
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: this and super
 
Similar Threads
User defined unchecked exceptions
how to deal with this string?
WA #1.....word association
constructors example
coreJava