If i have following code for a Java program
class Dotcom{
private int positions[];// position is reference variable at class level
//some other instance variables
// suppose here we have setter for initialising "positions"
public void Somefun (){
int modifier [positions.length];
// code for initialising "modifier"
positions = modifier;
}
}
So my question is that when Somefun
function returns then the portion of memory to which modifier is referencing will be eligible for garbage collection as modifier is destroyed.So does the statement
positions = modifier;
makes sense as now to which area of memory positions
is referencing?