Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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..??
Posted
Comments
Richard MacCutchan 3-Jan-14 12:44pm    
Primitives are created directly on the stack and disappear when they go out of scope. There is no garbage collection of them.
shchandhu 3-Jan-14 12:46pm    
can primitives be created on heap..??
shchandhu 3-Jan-14 12:47pm    
thnq
shchandhu 3-Jan-14 12:49pm    
my stupid asking that whether garbage collection wont be done on stack..??
CPallini 3-Jan-14 12:57pm    
The stack has its 'own management', the garbage collector acts on the heap.

1 solution

 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 3-Jan-14 14:11pm    
Good link, a 5.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900