wood burning stoves 2.0*
The moose likes Java in General and the fly likes Static method - Non static variables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Static method - Non static variables" Watch "Static method - Non static variables" New topic
Author

Static method - Non static variables

aakash bhatt
Ranch Hand

Joined: Jan 09, 2003
Posts: 182
is there any way to access Non-Static variables/methods from a static methd
Regards,
aakash
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Create an object of the class and get them thru the instance. You have to remember that the reason you can't access instance variables and methods from a static context is that static methods are not polymorphic which means that the compiler links the method at compile time, not runtime like. So the compiler has no way of knowing what instance (if any) to use.


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Static method - Non static variables