Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Robert Klemme Newsgroups: comp.lang.java.programmer Subject: Re: StringBuilder Difficulties Date: Sun, 03 Jul 2011 12:35:23 +0200 Lines: 23 Message-ID: <97auvhFt73U1@mid.individual.net> References: <971fj1Fg1rU1@mid.individual.net> <7c5d329e-6db5-4b52-8501-b9ae9c3a8738@k23g2000pri.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net XPz8J/7nUENL0MM0Ieku+g+1DY9018CocM4bXNFP4KOTr51f4= Cancel-Lock: sha1:6z/w/5CJJEW2idclvhGFan7nEL4= User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.18) Gecko/20110616 Lightning/1.0b2 Thunderbird/3.1.11 In-Reply-To: <7c5d329e-6db5-4b52-8501-b9ae9c3a8738@k23g2000pri.googlegroups.com> Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:5831 On 03.07.2011 09:08, lewbloch wrote: > The efficiency doesn't come from the re-use of the 'StringBuilder' > object from iteration to iteration. The create/destroy mechanism for > short-lived objects favors creating the temporary object inside the > loop, not outside. The efficiency comes from not having to create so > many superfluous 'String' objects. Lew, I find that explanation a bit strange: only reuse of StringBuilder makes it possible to not have to create all those superfluous String instances. You make it sound as if reuse and not having to create superfluous String objects are somehow antithetic or independent. If I cannot use a StringBuilder and I want to construct a String from parts I have to create superfluous String instances - so both facts are really related. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/