Java Reference
In-Depth Information
StubFinder
applicationtosplitastring'scomma-separatedlistofvaluesintoanarray
of
String
objects.Thismethodusesaregularexpressionthatidentifiesasequenceof
characters around which the string is split. (I discuss regular expressions in Appendix
C.)
Note
StringIndexOutOfBoundsException
and
ArrayIn-
dexOutOfBoundsException
are sibling classes that share a common
java.lang.IndexOutOfBoundsException
superclass.
StringBuffer and StringBuilder
String
objects are immutable: you cannot modify a
String
object's string. The
various
String
methods that appear to modify the
String
object actually return
a new
String
object with modified string content instead. Because returning new
String
objects is often wasteful, Java provides the
java.lang.StringBuffer
and
java.lang.StringBuilder
classes as a workaround. These classes are
identicalapartfromthefactthat
StringBuffer
canbeusedinthecontextofmultiple
threads (discussed later in this chapter), and that
StringBuilder
is faster than
StringBuffer
butcannotbeusedinthecontextofmultiplethreadswithoutexplicit
synchronization (also discussed later in this chapter).
izing
StringBuffer
objects and working with string buffers.
StringBuilder
's
constructors and methods are identical.