File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 18103
    
  39

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[]
 
Similar Threads
valueOf( ) and toString( )
Mixing of code - raw and generic
Why strange output of this String question
Reflection determining return Type as String?
Calling a new JSP form a Spring Controller using Ajax