• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Where do static variables (class variables) live (scope)?

 
satya mamillapalli
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where do they live? stack or heap?

They belong to class not object so does they belong on stack..

Please Advise..
[ August 28, 2005: Message edited by: satya mamillapalli ]
 
amit taneja
Ranch Hand
Posts: 813
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
object are always be on heap whether its static or not

and static variable will be on stack of Class object which is object of this object ... if i am wrong..pls correct me
 
satya mamillapalli
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do they live on stack or heap?
 
Megs Maquito
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
local variables live on the stack, class variables,hmmm if a class is instantiated then the object lives in the heap along with it's instance variables & instance methods be they static or non-static.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic