Scala Iterator mkString() method with a separator with example
Last Updated :
13 Aug, 2019
This method is same as mkString() method but here a separator is included.
Method Definition: def mkString(sep: String): String
Return Type: It returns the string representation of the stated collection with a given separator.
Example #1:
object GfG
{
def main(args : Array[String])
{
val iter = Iterator( 1 , 2 , 3 , 5 )
val result = iter.mkString( "*" )
println(result)
}
}
|
Example #2:
object GfG
{
def main(args : Array[String])
{
val iter = Iterator( 1 , 2 , 3 , 5 )
val result = iter.mkString( "0" )
println(result)
}
}
|
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...