It's not a secret anymore!
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes using plus inside StringBuffer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply locked New topic

using plus inside StringBuffer

kundan varma
Ranch Hand

Joined: Mar 08, 2004
Posts: 323
HI all
Suppose i have 3 variables. If i write like this
StringBUffer sb = new StringBuffer("[");
Is this code creating new string objects because of using + inside append.


Failures are practice shoots for success.
Vicky Jain
Ranch Hand

Joined: Aug 02, 2003
Posts: 52
Yups kundan,

Those string were created in the String pool.

[ August 25, 2004: Message edited by: Vicky Jain ]

SCJP1.4(96%)<br />A drop of ink can make millions think.
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
This is a duplicated topic so I'm closing it. Please post your responses here
[ August 25, 2004: Message edited by: Barry Gaunt ]

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
I agree. Here's the link:
subject: using plus inside StringBuffer
It's not a secret anymore!