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)
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: 9707
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
Don't get me started about those stupid
light bulbs
.
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...