Link to home
Start Free TrialLog in
Avatar of Jay Roy
Jay RoyFlag for United States of America

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.
ASKER CERTIFIED SOLUTION
Avatar of Sharon Seth
Sharon Seth
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jay Roy

ASKER

although it is declared locally within a method ?
The reference to the instance is stored on the stack. The instance itself is stored in the heap, like all objects, as sharonseth said.
Avatar of Jay Roy

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.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial