Can you tell me how long a variable lives in a program (in Java). i.e. variables declared inside methods, variables used in parameters, STATIC variables, variables used to return from a method, etc.
Thanks.
Can you tell me how long a variable lives in a program (in Java). i.e. variables declared inside methods, variables used in parameters, STATIC variables, variables used to return from a method, etc.
Thanks.
Objects in Java are guaranteed to live as long as they are referenceable through a transitive closure of the root set. This is a conservative approximation of the application's live objects¹.
Edit: Is this question concerning object lifetime, or variable scope? We have some mixed terminology going on.
¹ A live object is an object that will be referenced again before the application terminates.