This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Number of objects created in StringBuilder ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Number of objects created in StringBuilder ?" Watch "Number of objects created in StringBuilder ?" New topic
Author

Number of objects created in StringBuilder ?

Lovleen Gupta
Ranch Hand

Joined: Feb 26, 2007
Posts: 63
I know -- if it had been string here like ::
String s = new String("abc");
2 objects are created.

But, how many objects are created when we say --

StringBuilder sb = new Stringbuilder("abc");

Thanks.
Vassili Vladimir
Ranch Hand

Joined: Mar 08, 2007
Posts: 1585
Hallo,

When using StringBuffer, the case is one-by-one, meaning, one object and one reference.

So, when we say:



There will be this one object on the heap with stringBuffer referring to it.

Good luck ...


Vassili ...
SCJP 5.0, SCWCD 1.4, SCJA 1.0
Vassili Vladimir
Ranch Hand

Joined: Mar 08, 2007
Posts: 1585
Sorry i forgot to say that StringBuffers don't go to the String constant pool.

 
wood burning stoves
 
subject: Number of objects created in StringBuilder ?
 
Similar Threads
Hom many Objects are created ???
String literal objects in String pool
Stings: how many objects created?
String Builders
How Many Objects?