Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Declaring variables in constructor?

 
Anto Telvin
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all
If we are declaring/initializing a variable in constructor what type of variable is that local or class ? and where it is going to store in heap or stack


thanks in advance
 
Henry Wong
author
Marshal
Pie
Posts: 20995
76
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, if you are declaring, obviously, it is a local variable. If you are initializing, then it depends on how the variable was declared.

Whether a variable is on the heap or stack depends on the type of variable. Beginning with Java 6, this is further complicated with escape analysis.

Henry
 
Anto Telvin
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic