It does not depend on whether it is a primitive data type or not, It
depends on whether it is an Instance variable or a local variable.
All local variables are stored in the stack along with their methods within which they are declared.
All instance variables/objects which contain primitive types are stored on the heap even if they are declared inside a method.Only their references stay in the stack if declared inside a method.
All local variables are stored in the stack along with their methods within which they are declared.
All instance variables/objects which contain primitive types are stored on the heap even if they are declared inside a method.Only their references stay in the stack if declared inside a method.
No comments:
Post a Comment