Stack and heap are both memories of RAM. Stack is a common place for most of memory storage. Both of these allocated memory inside jvm. Heap is a dedicated memory storage created only when we initialize using the new operator. They are easily freed or garbage collected when no more required. Objects created from classes are stored in heap. Eg int is stack managed and Integer is heap managed. Storage algorithm is different. Stack initialized may not properly manage contigious memory and may waste memory. Each heap initalized gets contigious memory. After object is freed memory re-organizes to claim original space and re constructs to leave no free space betwn two managed objects
--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "The Java Posse" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/javaposse?hl=en -~----------~----~----~----~------~----~------~--~---
