Linked ListsConcrete Mutable Collection ClassesList BuffersStringBuildersContents

StringBuilders

Just like an array buffer is useful for building arrays, and a list buffer is useful for building lists, a StringBuilder is useful for building strings. String builders are so commonly used that they are already imported into the default namespace. Create them with a simple new StringBuilder, like this:

scala> val buf = new StringBuilder
buf: StringBuilder = 
scala> buf += 'a'
res38: buf.type = a
scala> buf ++= "bcdef"
res39: buf.type = abcdef
scala> buf.toString
res41: String = abcdef

Next: Linked Lists


Linked ListsConcrete Mutable Collection ClassesList BuffersStringBuildersContents