Scala BitSet addString(b: StringBuilder, sep: String) method with separator
Scala Bitsets are sets of non-negative integers which are represented as variable-size arrays of bits packed into 64-bit words. The addString(sb: mutable.StringBuilder, start: String, sep: String, end: String)
method is utilised to appends all elements of this bitset to a string builder using a separator string.
Method Definition: def addString()
Return Type: It returns the string builder b to which elements were appended.
Example #1:
import scala.collection.immutable.BitSet
object GfG
{
def main(args : Array[String])
{
val bitSet : BitSet = BitSet( 11 , 22 , 33 , 44 )
val b = new StringBuilder()
val bs 1 = bitSet.addString(b, ", " )
println(bs 1 )
}
}
|
Example #2:
import scala.collection.immutable.BitSet
object GfG
{
def main(args : Array[String])
{
val bitSet : BitSet = BitSet( 1 , 2 , 3 )
val b = new StringBuilder()
val bs 1 = bitSet.addString(b, "-Geek- " )
println(bs 1 )
}
}
|
Output:
1-Geek- 2-Geek- 3
Last Updated :
04 May, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...