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..??

Edit/Delete Message

It depends...
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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.