This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 9044
    
  10
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
 
Similar Threads
Do static variables, methods impose a penalty
help me plz
Methods memory allocation
Methods
JButton