Sun Certified Java Programmer
Sun Certified Java Programmer
Sun Certified Java Programmer
Jane Griscti
SCJP, Co-author Mike Meyers' Java 2 Certification Passport
Originally posted by Tom Tang:
Can somebody explain this for me?
class Try {
public static void main(String[] args) {
String sb1 = "good";
String sb2 = "";
System.out.println(sb1==sb1+sb2);
}}
Output is false. It seems sb1+sb2 creates a new String, because String is immutable;
Originally posted by Jane Griscti:
Hi all,
When you create a String using [b]new or when the String is the result of a runtime operation Java creates a new object.
[/B]
A new class instance is implicitly created when the string concatenation operator + (�15.18.1) is used in an expression,
resulting in a new object of type String (�4.3.3)
Jane Griscti
SCJP, Co-author Mike Meyers' Java 2 Certification Passport
Regards<br />Mohammod Wahid Sadik<br />SCJP 1.2, SCJD 1.4,<br />IBM Certified XML Developer<br />IBM Certified UML Designer
If I had asked people what they wanted, they would have said faster horses - Ford. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
|