Scala Iterator addString() method with example
The addString() method belongs to the concrete value members of the class AbstractIterator. It is defined in the class IterableOnceOps. It is utilized to append the elements of the Scala Iterator to a String Builder.
Method Definition : def addString(b: StringBuilder): StringBuilder
Return Type : It returns the String Builder to which the elements were appended.
Example #1:
object GfG
{
def main(args : Array[String])
{
val iter = Iterator( 7 , 6 , 8 , 1 )
val result = iter.addString( new StringBuilder())
println(result)
}
}
|
Example #2:
object GfG
{
def main(args : Array[String])
{
val iter = Iterator( 7.7 , 6.1 , 8.6 , 1.1 )
val result = iter.addString( new StringBuilder())
println(result)
}
}
|
Last Updated :
30 Jun, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...