Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJP
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Programmer Certification (OCPJP)
Number of objects created in StringBuilder ?
Lovleen Gupta
Ranch Hand
Posts: 63
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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
Posts: 1585
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hallo,
When using StringBuffer, the case is one-by-one, meaning, one object and one reference.
So, when we say:
StringBuffer stringBuffer=new StringBuffer("Hallo");
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
Posts: 1585
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Sorry i forgot to say that StringBuffers don't go to the String constant pool.
Vassili ...
SCJP 5.0, SCWCD 1.4, SCJA 1.0
Consider Paul's
rocket mass heater
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
String literal objects in String pool
String Builders
How Many Objects?
Stings: how many objects created?
Hom many Objects are created ???
More...