Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Constructer variables

 
santhosh.R gowda
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the scope of variables declared inside constructer...... and where does the constructers occupy memory whether in heap or stack....
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15207
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Variables declared inside a constructor work exactly the same as local variables declared in a method. The scope is ofcourse the enclosing block (which might be the constructor itself). Variables are allocated on the stack, and objects are always allocated on the heap.
 
santhosh.R gowda
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks very much ...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic