The Artima Developer Community
Sponsored Link

Legacy Design Forum
Designing with Static Members



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


Static Methods

Posted by Sayari on November 12, 2001 at 10:07 PM

When you create an instance of a class, memory is allocated for variables you declared, and each instance of the class has different memory space, so they do not overwrite each other. Static makes the variable belongs to the class, not that instance of the clas, all instance of that class will be refering to the same variable in memory.
Now, Static methods are called before the instance of the class is created. (Public static void main(String args[]{}).
It does not have "this" operator and cant use "super" keyword. It is not allowed to access the not static members of the class.


> Hi,
> I know that static variable have only one copy. Every new object of that class won't have that static variable.
> Is it the same with static method? Does method also stored in the memory like the variable?
> I also know that static block are executed only once when the class is loaded, but how about static method?

> Thanks


Sponsored Links

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