strings in java  
Author Message
Boudewijn Dijkstra





PostPosted: 2004-5-30 18:52:00 Top

java-programmer, strings in java As a response to a request to "make a complete and concise statement" and
"to provide some context", I reply here to my own post.

"Boudewijn Dijkstra" <email***@***.com> schreef in bericht
news:40b5afde$0$41748$email***@***.com...
> "Tony Morris" <email***@***.com> schreef in bericht
> news:c91dr1$i3c$email***@***.com...
> > "Ace" <email***@***.com> wrote in message
> > news:s0Usc.167024$email***@***.com...
> > > Now what if you had: String str ="abc"+" "+"def"+"efg";
> >
> > The compiler creates a single String instance with the value "abcdefefg"
>
> It becomes "abc defefg", actually.
> It is
remove "It is"
insert "The exact same string can be"
> created with the following Java statement:
> new StringBuffer().append("abc").append(" ")
> .append("def").append("efg").toString()

Maybe I am just too flexible in my use of language.


 
Boudewijn Dijkstra





PostPosted: 2004-5-30 18:52:00 Top

java-programmer >> strings in java As a response to a request to "make a complete and concise statement" and
"to provide some context", I reply here to my own post.

"Boudewijn Dijkstra" <email***@***.com> schreef in bericht
news:40b5afde$0$41748$email***@***.com...
> "Tony Morris" <email***@***.com> schreef in bericht
> news:c91dr1$i3c$email***@***.com...
> > "Ace" <email***@***.com> wrote in message
> > news:s0Usc.167024$email***@***.com...
> > > Now what if you had: String str ="abc"+" "+"def"+"efg";
> >
> > The compiler creates a single String instance with the value "abcdefefg"
>
> It becomes "abc defefg", actually.
> It is
remove "It is"
insert "The exact same string can be"
> created with the following Java statement:
> new StringBuffer().append("abc").append(" ")
> .append("def").append("efg").toString()

Maybe I am just too flexible in my use of language.