Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Re: Re: Re: Memory Use/Garbage Collection: Java vs Perl

by hossman (Prior)
on Sep 04, 2002 at 00:37 UTC ( [id://194950]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Re: Memory Use/Garbage Collection: Java vs Perl
in thread Memory Use/Garbage Collection: Java vs Perl

this whole thread is pretty OT, so i won't let that stop me from pointing out...

You aren't garunteed to get the behavior you are seeing from every implimentation of Java -- the JLS only requires that string concatination must be implimented using a StringBuffer, not that multiple string concatenations must be optimized into a single StringBuffer.

ie...

this... String foo = "bar" + "baz"; is garunteed to be equivilent to this... StringBuffer tmp = new StringBuffer("bar"); tmp.append("baz"); String foo = tmp.toString(); But this... String wb = "yakko" + "wakko" + "dot"; might be implimented as... StringBuffer tmp1 = new StringBuffer("yakko"); tmp1.append("wakko"); String tmp2 = tmp1.toString(); StringBuffer tmp3 = new StringBuffer(tmp2); tmp3.append("dot"); String wb = tmp3.toString();

You might want to check out JDC TechTip 2002-03-05 particularly it's discussion of "a statement found in the Java Language Specification section 15.18.1.2"

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://194950]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2024-04-18 07:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found