Scala List addString() method with example
The addString() method is utilized to append all the elements of the list to a string builder.
Method Definition: def addString(b: StringBuilder): StringBuilder
Return Type: It returns the elements of the list to a string builder.
Example #1:
object GfG
{
def main(args : Array[String])
{
val m 1 = List( 1 , 3 , 5 , 2 )
val res = m 1 .addString( new StringBuilder())
println(res)
}
}
|
Example #2:
object GfG
{
def main(args : Array[String])
{
val m 1 = List( 1 , 1 , 5 , 2 )
val res = m 1 .addString( new StringBuilder())
println(res)
}
}
|
Last Updated :
26 Jul, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...