14.07.2013 Views

Contents - Cultural View

Contents - Cultural View

Contents - Cultural View

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

String Buffer 282<br />

As well, the shortcomings of arrays are inherent in a StringBuffer. In order to insert or remove characters are<br />

arbitrary positions, whole sections of arrays must be moved.<br />

The method by which a StringBuffer is attractive in an environment with low processing power takes this ability by<br />

using too much memory, which is likely also at a premium in this environment. This point, however, is trivial,<br />

considering the space required for creating many instances of Strings in order to process them. As well, the<br />

StringBuffer can be optimized to "waste" as little memory as possible.<br />

The StringBuilder class, introduced in J2SE 5.0, differs from StringBuffer in that it is unsynchronized. When only a<br />

single thread at a time will access the object, using a StringBuilder is more efficient than using a StringBuffer.<br />

StringBuffer and StringBuilder are included in the java.lang package.<br />

In .NET<br />

Microsoft's .NET Framework has a StringBuilder class in its Base Class Library.<br />

See also<br />

• Analysis of algorithms<br />

Links<br />

• The JavaDocs of StringBuffer [1] , StringBuilder [2] and String [3] , as well as the article StringBuffer and<br />

StringBuilder.<br />

• The source code of these classes [4]<br />

• Urban Performance Legends [5] - An article which involves a discussion of immutable objects with respect to<br />

object-oriented design<br />

References<br />

[1] http:/ / java. sun. com/ j2se/ 1. 5. 0/ docs/ api/ java/ lang/ StringBuffer. html<br />

[2] http:/ / java. sun. com/ j2se/ 1. 5. 0/ docs/ api/ java/ lang/ StringBuilder. html<br />

[3] http:/ / java. sun. com/ j2se/ 1. 5. 0/ docs/ api/ java/ lang/ String. html<br />

[4] http:/ / www. java2s. com/ Code/ JavaAPI/ java. lang/ StringBuffer. htm<br />

[5] http:/ / www-128. ibm. com/ developerworks/ java/ library/ j-jtp04223. html?ca=dgr-lnxw01JavaUrbanLegends

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!