aspose file tools*
The moose likes Beginning Java and the fly likes asking about static n non static memory difference Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "asking about static n non static memory difference " Watch "asking about static n non static memory difference " New topic
Author

asking about static n non static memory difference

kumar abhay
Ranch Hand

Joined: Oct 02, 2001
Posts: 53
hi there,
its been a long time n have a question again.i want to know about the memory difference betwen a static n a non-static variable.how much memory they alocate n exactly wat difference is made when a static or a non static vriable is used.i mean what is the criteria for using a static or a non static variables.i hope that u ppl will reply me asap.
take care
with regards
kumar abhay
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
If you have a variable that should be shared by all instances of a class, then declare it static, since only one static variable exists for the entire class and sunclasses. Since only one static variable exists it takes less memory than instance variables which exixt for each instance of the class.

Bosun
------------------
Bosun
SCJP for the Java� 2 Platform


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9052
    
  12
I want to know about the memory difference betwen a static and a non-static variable, how much memory they allocate and what is the criteria for using a static or a non static variable.

How much memory each variable allocates is independent of whether the variable is static or not.


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
kumar abhay
Ranch Hand

Joined: Oct 02, 2001
Posts: 53
hi there,
thanks alot it helped me alot.
take care
with regards
kumar abhay
 
jQuery in Action, 2nd edition
 
subject: asking about static n non static memory difference