Content deleted Content added
m interwiki to Spanish; <code> tags |
|||
Line 16:
=== Implications ===
Generally, a <code>StringBuffer</code> is more [[analysis of algorithms|efficient]] than a String in string handling. However, this is not necessarily the case, since a StringBuffer will be required to recreate its character array when it runs out of space. Theoretically, this is possible to happen the same number of times as a new String would be required, although this is unlikely (and the programmer can provide length hints to prevent this). Either way, the effect is not noticeable in modern desktop computers.
As well, the shortcomings of arrays are inherent in a <code>StringBuffer</code>. In order to insert or remove characters at arbitrary positions, whole sections of arrays must be moved.
The method by which a <code>StringBuffer</code> 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> processes more efficiently than using a <code>StringBuffer</code>.
Line 27:
== In .NET ==
Microsoft's [[.NET Framework]] has a <code>StringBuilder</code> class in its [[Base Class Library]].
== In other languages ==
Line 44:
[[Category:String data structures|Buffer]]
[[es:Búfer de cadena]]
[[ja:StringBufferとStringBuilder]]
|