This week's giveaway is in the Threads forum.
We're giving away four copies of Java Concurrency Live Lessons and have Doug Schmidt on-line!
See this thread for details.
Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

instance variables  RSS feed

 
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
Boost this thread!