Scala List mkString() method with example
Last Updated :
13 Aug, 2019
The mkString() method is utilized to display all the elements of the list in a string.
Method Definition: def mkString: String
Return Type: It returns all the elements of the list in a string.
Example #1:
object GfG
{
def main(args : Array[String])
{
val m 1 = List( 2 , 3 , 5 , 7 , 8 )
val result = m 1 .mkString
println(result)
}
}
|
Example #2:
object GfG
{
def main(args : Array[String])
{
val m 1 = List( 2 , 3 , 5 , 7 , 5 )
val result = m 1 .mkString
println(result)
}
}
|
Share your thoughts in the comments
Please Login to comment...