Update Stack vs Heap memory in Java