jQuery in Action, 3rd edition
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes static Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "static" Watch "static" New topic


arivu mathi
Ranch Hand

Joined: Jun 26, 2006
Posts: 38
can we use this reference inside a static method or a class?
can we use static and native together?
can anyone explain this?
Arafat Nalkhande
Ranch Hand

Joined: Jul 20, 2006
Posts: 51
We cannot use 'this' refernce inside the static methods.
Reason for it is that 'this' belongs to an instance whereas static stuff does not belong to any particular instance, but to the class in general.

I want to be myself, but a better myself.<br />~ SCJP 1.4 (91%), SCWCD 1.4 (86%) ~
Gowher Naik
Ranch Hand

Joined: Feb 07, 2005
Posts: 643
this is non static and cannot be refered from static context.
A method can be both native and staic.
Don't get me started about those stupid light bulbs.
subject: static
It's not a secret anymore!