• 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
Pie
Posts: 15369
40
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 ...
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic