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