Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #8140

Re: StringBuilder

From Jan Burse <janburse@fastmail.fm>
Newsgroups comp.lang.java.programmer
Subject Re: StringBuilder
Date 2011-09-18 22:13 +0200
Organization albasani.net
Message-ID <j55jcp$9im$1@news.albasani.net> (permalink)
References (3 earlier) <vp7a77lp3e5oe4h79pnmv95vb4lu13spmc@4ax.com> <GeednbWNqODBGOjTnZ2dnUVZ_rqdnZ2d@posted.palinacquisition> <j54nc9$tgk$1@dont-email.me> <j54rss$j3q$1@news.albasani.net> <j54svs$u9u$1@dont-email.me>

Show all headers | View raw


Eric Sosman schrieb:
>      I do not know whether buffer-sharing was dropped before, after,
> or with the introduction of StringBuilder.

The implementation advice comment was removed in 1.5 javadoc.
It was still present in 1.4.1 javadoc:


1.4.1 javadoc:

Converts to a string representing the data in this string buffer. A new 
String object is allocated and initialized to contain the character 
sequence currently represented by this string buffer. This String is 
then returned. Subsequent changes to the string buffer do not affect the 
contents of the String.

Implementation advice: This method can be coded so as to create a new 
String object without allocating new memory to hold a copy of the 
character sequence. Instead, the string can share the memory used by the 
string buffer. Any subsequent operation that alters the content or 
capacity of the string buffer must then make a copy of the internal 
buffer at that time. This strategy is effective for reducing the amount 
of memory allocated by a string concatenation operation when it is 
implemented using a string buffer.

http://download.oracle.com/javase/1.4.2/docs/api/java/lang/StringBuffer.html#toString%28%29





1.5 javadoc:

Returns a string representing the data in this sequence. A new String 
object is allocated and initialized to contain the character sequence 
currently represented by this object. This String is then returned. 
Subsequent changes to this sequence do not affect the contents of the 
String.

http://download.oracle.com/javase/1.5.0/docs/api/java/lang/StringBuffer.html#toString%28%29



Bye

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Re: StringBuilder Stanimir Stamenkov <s7an10@netscape.net> - 2011-09-17 19:56 +0300
  Re: StringBuilder Jan Burse <janburse@fastmail.fm> - 2011-09-17 20:35 +0200
  Re: StringBuilder Roedy Green <see_website@mindprod.com.invalid> - 2011-09-17 15:34 -0700
    Re: StringBuilder Jan Burse <janburse@fastmail.fm> - 2011-09-18 01:33 +0200
      Re: StringBuilder Jan Burse <janburse@fastmail.fm> - 2011-09-18 01:56 +0200
      Re: StringBuilder Roedy Green <see_website@mindprod.com.invalid> - 2011-09-17 20:58 -0700
    Re: StringBuilder Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2011-09-17 22:44 -0700
      Re: StringBuilder Jan Burse <janburse@fastmail.fm> - 2011-09-18 09:54 +0200
        Re: StringBuilder Jan Burse <janburse@fastmail.fm> - 2011-09-18 09:59 +0200
        Re: StringBuilder Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2011-09-18 07:28 -0700
      Re: StringBuilder Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-09-18 08:15 -0400
        Re: StringBuilder Jan Burse <janburse@fastmail.fm> - 2011-09-18 15:32 +0200
          Re: StringBuilder Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-09-18 09:50 -0400
            Re: StringBuilder Stanimir Stamenkov <s7an10@netscape.net> - 2011-09-18 17:08 +0300
            Re: StringBuilder Jan Burse <janburse@fastmail.fm> - 2011-09-18 22:13 +0200
              Re: StringBuilder Jan Burse <janburse@fastmail.fm> - 2011-09-18 22:29 +0200
                Re: StringBuilder Jan Burse <janburse@fastmail.fm> - 2011-09-18 22:39 +0200
      Re: StringBuilder Roedy Green <see_website@mindprod.com.invalid> - 2011-09-19 09:45 -0700

csiph-web