Jay Roy
asked on
object instantiation in local method
public class Test{
private void myMethod(){
...
Customer c = new Customer(); //is this object stored in heap or stack ?
...
}
}
Any help appreciated
thanks.
private void myMethod(){
...
Customer c = new Customer(); //is this object stored in heap or stack ?
...
}
}
Any help appreciated
thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The reference to the instance is stored on the stack. The instance itself is stored in the heap, like all objects, as sharonseth said.
ASKER
>>The reference to the instance is stored on the stack
what do you mean by 'reference to the instance', can you explain a bit more?
thanks.
what do you mean by 'reference to the instance', can you explain a bit more?
thanks.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER