I was a puzzled with memory management in java. Everywhere it is written that local variable is given memory in stack. And if that local variable is of object type, then it is given memory in heap. I want to know where does JVM allocates memory for local object reference variable with value null.
public void show(){
Animal animal = null;
}
where does the JVM allocates memory for animal object. Is it in stack? or it does not give any memory because it is marked null. I am sure it is not given memory in heap.
can any one clear away my doubts.