Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

asking about StringBuffer memory location

 
kumar abhay
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi there,
i hope u ppl r doin' fine.i have a question regarding string buffer.All string laterals r saved in pool but StringBuffer in not saved in pool.
Q.1 where stringbuffer is saved?
Q.2 y it does not save in pool does it have any other memory location n y it is categorized to be saved at a different place.
i m sure that u ppl will replay me asap.thanx in advance.
take care
with regards
kumar abhay
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kumar,
The string pool is a place in memory that doesn't ever get changed. Items can be inserted into and removed from it (by compiler and gc) but the item contents are all immutable.
Strings are saved in a pool because they are immutable. That means that once created they can't be changed.
StringBuffers on the other hand can be changed. That is why they aren't saved in the String pool.
Regards,
Manfred.
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They are created out on the heap where most objects exist.
 
Sadaf Zaidi
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You Manfred now its clear.
 
kumar abhay
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi there,
tahnks alot for solving my problem n your kind concern regarding my problem.i hope that your help will be continued in the future as well.
take care
with regards
kumar abhay
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic