This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

usng StringBuffer

 
Haris Karameh
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when using StringBuffer for efficiency, what exactly is the result of

StringBuffer sb=new StringBuffer();
sb.append...
sb.append...
System.out.println(sb.toString());

What is happening when calling sb.toString().
Is new memory space alocated to accomodate the content of sb, and the content copied to new location, and after recycled?
 
Bupjae Lee
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is implemention of StringBuffer.toString()


Is new memory space alocated to accomodate the content of sb, and the content copied to new location, and after recycled?


You're right.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic