wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes this and super Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
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: 60782
    
  65

As they refer to instances, and, by definition, there are no instances associate with static methods, how could that make any sense?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by 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: 60782
    
  65

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://aspose.com/file-tools
 
subject: this and super
 
Similar Threads
how to deal with this string?
User defined unchecked exceptions
WA #1.....word association
constructors example
coreJava