aspose file tools*
The moose likes Beginning Java and the fly likes Refrence to and Integer[] being returned scope of Integer[] Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Refrence to and Integer[] being returned scope of Integer[]" Watch "Refrence to and Integer[] being returned scope of Integer[]" New topic
Author

Refrence to and Integer[] being returned scope of Integer[]

Chadd Franck
Ranch Hand

Joined: Nov 05, 2008
Posts: 50
In the following code, I'm assuming the copy of the reference newStats is being returned to the calling method, but does the array die out when the method(gerAllStats) completes, setting the values all to null.

What is the life of Integer[] obj?

Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

What is the life of Integer[] obj?


When the method returns, the newStats reference goes out of scope and can't be used to reach the Integer array object. As for the Integer array object, that would depends on what happens after the method returns. If another reference refers to it, it will remain reachable, and live on.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Refrence to and Integer[] being returned scope of Integer[]