Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

diffrence b/w heap and pool

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello all..
i m not getting whats the exactly diffrence b/w heap and pool. please discribe it breifly.

thanks

vinay
 
arch rival
Posts: 2813
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure your question has any meaning. The internals of compilers decide if information is on the heap or stack and in Java there is a String pool, but that is a separate issue.
 
Ranch Hand
Posts: 193
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Vinaykumar-

From what I've read, basically all you have to know about the heap and the stack for the exam is that local variables (variables declared inside of methods) live on the stack and objects and instance variables live on the heap.

Also know when an object is eligible for garbage collection.

Like Marcus said, Java also uses a String pool for optimization. Basically if you create a reference to a String literal, Java looks in a special section of memory for a matching String literal. If there's one there, then it points the reference at that String literal. If not, it creates a new String literal. If you use the new keyword (String myString = new String("blah") ;) , then it skips using the String pool altogether and creates a new String literal just like any other object. There's usually no need to do this and many coding standards prohibit creating Strings with the new keyword. You might have to have some knowledge of this stuff for the exam, but for the real world I think it basically comes down to never using the new keyword with Strings and always using myString.equals(otherString) instead of == to compare Strings.

Hope that helps.
Josh

[ February 05, 2006: Message edited by: Joshua Smith ]
[ February 05, 2006: Message edited by: Joshua Smith ]
 
Marcus Green
arch rival
Posts: 2813
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my experience of the Sun Certified Java programmers exam (going back to 1998) there have never been any questions that expect knowledge of the heap and Stack, but you do need to understand the String pool.
 
reply
    Bookmark Topic Watch Topic
  • New Topic