• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

instance variables

 
Angela lewis
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
local variables are always on the stack.
But where are instance variables?
is it the stack or something else?
 
Sundar Murthi
Ranch Hand
Posts: 209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Instance variables are in memory.
When ever an new object is created its instance variables are allocated in object refference memory.Ie object itself contains the instance variables.

The name "instance variable " itsef u can understand that one

i hope it will help u
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
instance variables live on the heap, which is basically just a raw chunk of RAM managed by the JVM.

Think of the stack as the queue in front of the checkin desk at an airport, the heap would be the departure launch where everyone mingles with no apparent order but will get to the right exit in time.
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Think of the stack as the queue in front of the checkin desk at an airport


I wish it was. The last arrival would be first to get checked in!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic