wood burning stoves*
The moose likes Beginning Java and the fly likes Declaring variables in constructor? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Declaring variables in constructor?" Watch "Declaring variables in constructor?" New topic
Author

Declaring variables in constructor?

Anto Telvin
Ranch Hand

Joined: Aug 12, 2008
Posts: 113
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


Anto Telvin Mathew<br />Many of the life failures are people who did not realize how close they were to success when they give up. EDISON
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18138
    
  39

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


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Anto Telvin
Ranch Hand

Joined: Aug 12, 2008
Posts: 113
thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Declaring variables in constructor?
 
Similar Threads
Cannot Figure Out This Syntax Error
Overloading constructors.
meaning??
char to int
Errors when reading and writing from a text file - any help!!