i started learing java
reading thinking in java
i cam across this
java objects do not have same lifetime as primitives
an object retains in memory even after its scope until garbage collector detects and releases the memory
well whats the lifetime of primitives..??
their memory will be released after the scope..??
For primitives that are local variables declared inside methods or other blocks, and for method parameters, they are allocated on the stack and released as soon as they go out of scope.
For primitives that are declared as static members of a class, the lifetime is the same as the program's.
For primitives that are instance members of a class, their lifetime is the same as that of the instance in which they were created.