The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
January 2001



This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.



Posted by saddy on January 31, 2001 at 1:37 PM

Hi alex,
in object oriented language every instance variables has to be associated with some object, but static methods are called without objects that is with there class names , now if u are makeing any changes in non-static instance variables than with which objects are they associated.
u can make changes in the static vatiables because they are associated with the whole class and not with some particular objects.
with the similar reason u can not call any non-static method from the static method.

> Why can't you access non-static variables from a static context (e.g. the main method). In other words, what would be the consequences of doing this if it was allowed?

> thanx

> Alex


Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us