String Buffer: Difference between revisions

Content deleted Content added
merged stuff from StringBuilder article and then removed orphaned tag as it is not the case anymore
Line 1:
In [[object-oriented programming]], a '''String Buffer''' is an alternative to a String. It has the ability to be altered through adding or appending, whereas a String is normally fixed or unchangeable.
{{Orphan|date=November 2006}}
{{mergeto|StringBuffer and StringBuilder|date=May 2008}}
In [[object-oriented programming]], a '''String Buffer''' is an alternative to String. It has the ability to be altered through adding or appending, whereas a String is normally fixed or unchangeable.
 
== Java's approach ==
Line 23 ⟶ 21:
 
The method by which a StringBuffer is attractive in an environment with low processing power takes this ability by using too much memory, which is likely also at a premium in this environment. This point, however, is trivial, considering the space required for creating many instances of Strings in order to process them. As well, the StringBuffer can be optimized to "waste" as little memory as possible.
 
The '''{{Javadoc:SE|java/lang|StringBuilder}}''' class, introduced in [[Java Platform, Standard Edition|J2SE]] 5.0, differs from <code>StringBuffer</code> in that it is [[Synchronization (computer science)|unsynchronized]]. When only a single [[Thread (computer science)|thread]] at a time will access the object, using a <code>StringBuilder</code> is more efficient than using a <code>StringBuffer</code>.
 
<code>StringBuffer</code> and <code>StringBuilder</code> are included in the {{Javadoc:SE|package=java.lang|java/lang}} package.
 
== C++'s approach ==
Microsoft's .NET has a StringBuilder class in its [[Base Class Library]].
 
== See also ==
Line 29 ⟶ 34:
* [http://www-128.ibm.com/developerworks/java/library/j-jtp04223.html?ca=dgr-lnxw01JavaUrbanLegends Urban Performance Legends] - An article which involves a discussion of immutable objects with respect to [[object-oriented design]]
* [[Analysis of algorithms]]
 
{{mergeto|[[ja:StringBuffer and StringBuilder|date=May 2008}}]]
 
[[Category:Java programming language]]