File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Number of objects created in StringBuilder ?