Stringbuffer And Stringbuilder

In computer programming, the StringBuffer class is one of two core string classes in Java. Most of the time, the String class is used. The point of this class is it is a mutable object while String is immutable (see immutable object). That means the content of StringBuffer objects can be modifed while every methods of string class returns a new string and result in improving runtime efficiency. The StringBuilder, which is introduced by Java 1.5, differs from StringBuffer in that it is unsynchronized. StringBuffer and StringBuilder are included in the java.lang package. For example, following code uses StringBuffer instead of String for performance improvement.
 Reader reader = new FileReader("file"); char buf[] = new char10240; StringBuffer sbuf = new StringBuffer(0); while (reader.ready ()) { 
   sbuf.append(buf, 0, reader.read(buf)); 
}
Moreover, Java compiler (e.g., javac) usually uses StringBuffer to concatenate strings and objects joined by the additive operator. For example, one can expect: String s = "a + b = " + a + b; is translated to:
 StringBuffer sbuf = new StringBuffer (32); sbuf.append ("a + b = "); sbuf.append (a); sbuf.append (b); String s = sbuf.toString (); 
In the above code, a and b can be almost anything from primitive values to objects.

 

<< PreviousWord BrowserNext >>
siouan
national league pennant winners 1901 68
list of mayors of littleton, colorado
hugo theorell
pelham, new york
cubic function
merrill lynch
flashlight
mission of burma
skald
paul kariya
alex chiu
dion dimucci
trimline telephone
arthur pink
curved barbell
brocchinia reducta
himalayan
parabellum
grand chess
multiracial
2003 2004 occupation of iraq timeline
ttt
neil bush
how to specify a function
copper(ii) carbonate
tatary
john henry (album)
tokay gecko
tibetan language
elsa the lioness
franz von papen
system context diagram
studio ironcat
fred gallagher
coroutine
dogstar
alta
dorothy dunnett
crossing the chasm
mojave river
anthony woodville, 2nd earl rivers
agglutination
r. m. hare