The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
March 2001

Advertisement

Advertisement

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.

Message:

static keyword

Posted by tejinder singh on March 18, 2001 at 9:04 AM

hi sentil
it is right that static variables get initialized during compilation as they do not require an object to be initialized as the case with instance variables which come into existence only when an instance of a class is created.since static variables are object independent (thereby called class variables as they are property of class rather than object)hence the value of static variables is the same for all instances of the class.a change in the static variable by one instance changes its value for all variables.therefore the system only keeps one copy of static variables.
moreover in case of class which cannot be instantiated ,the methods of the class are declared as static so that they can be operated by classname since it is not possible to create an instance of that class.
hope this will clear the concept of static
thanks
tejinder



Replies:
  • friend senthil March 19, 2001 at 7:58 AM (1)

Sponsored Links



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