SCJP, SCWCD, SCBCD
who dare win!<br />SCJP5(94%)|SCWCD5(86%)|SCBCD(100%)|SCEA in progress
SCJP, SCWCD, SCBCD
SCJP, SCWCD, SCBCD
Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
SCJP 5.0
But as far as i know, the + operator gets resolved at the compile time and during the class loading operation, the concatenated string is available in the String Literal pool and ready to serve. Whereas in case of the methods like concat(), the concaneated string gets prepared only during runtime
SCJP, SCWCD, SCBCD
Note that this is true only for concatenation of strings that are compile-time constants. For example, this code points out a few subtleties:Originally posted by Raghavan Muthu:
But as far as i know, the + operator gets resolved at the compile time and during the class loading operation, the concatenated string is available in the String Literal pool and ready to serve.
SCJP 5.0
SCJP, SCWCD, SCBCD
SCJP, SCWCD, SCBCD
Originally posted by Deepak Jain:
Why doesnt JVM assign b to that string instead of constructing a new String object. Isn;t this waste of memory since Strings are immutable?
SCJP 5.0
SCJP, SCWCD, SCBCD
Originally posted by Deepak Jain:
One last thing to clarify is
So strings will be picked from string pool only during assignment?
like
String a = "aaa";
String b = "aaa";
SCJP 5.0
SCJP, SCWCD, SCBCD
all events occur in real time
The future belongs to those who believe in the beauty of their dreams.Dream BIG!
SCJP, SCWCD, SCBCD
Originally posted by Deepak Jain:
So it was good to know that concatenation should always be done with StringBuilder or StringBuffer based on synchronization needs and never with
+ or String.concat() .
SCJP 5.0
"I'm not back." - Bill Harding, Twister
Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Originally posted by Bert Bates:
... For those of you who are focused on the exam, you won't have to know this stuff.
Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
We're being followed by intergalactic spies! Quick! Take this tiny ad!
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|