See
java has two storage workable memory one is heap(for objects) and the stack for local var.
Heap comes in to play as soon as you create the object.GC runs on heap.
Whereas stack is generated for local calls like a method call and its destroyed by itself as soon as method call returns.
Their are lot more differences but the main i have listed above.