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
Tim Cooke
paul wheaton
Jeanne Boyarsky
Ron McLeod
Sheriffs:
Paul Clapham
Liutauras Vilda
Devaka Cooray
Saloon Keepers:
Tim Holloway
Roland Mueller
Bartenders:
Forum:
Programmer Certification (OCPJP)
Difference between String str = "" and String str = new String().
Brij Garg
Ranch Hand
Posts: 234
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Which one is better with respect to performance?
Flom Xanther
Ranch Hand
Posts: 48
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I would say,
String str = "asdf";
is more efficient, as this operation could reuse an existing String-Object from the
String
Literal Pool.
In opposite to
String str = new String("asdf");
which is always creating at least one brand new String-Object on the heap.
Regards,
Flom
Ankit Garg
Sheriff
Posts: 9708
43
I like...
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Just go through
this
article and then tell us if you still have any problems
...
SCJP 6 | SCWCD 5 |
Javaranch SCJP FAQ
|
SCWCD Links
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
setAttribute & getAttibute doubt
how many type or how many kind of way we can create an object in java??
Is String[ ] Serializabel?
String Question
question regarding strings
More...