It doesn't make sense to talk about 'memory of the caller' in Java. All the object instances reside in the same shared memory pool called Heap in the Java Virtual Machine. Memory does not belong to a specific method in Java. By the way, just to be clear on the terminology, funcA
and funcA
are most likely methods of some Class rather than functions.
With respect to assigning to a variable, you have to understand that in Java there are two ways of passing arguments:
- Primitive types are passed by value always
- Objects are passed by reference always
Assigning an object to a variable is just assigning a reference to the same object. You should assign to a variable only if it makes the code more clear, not because of memory concerns.