Home »
Code Examples »
Scala Code Examples
Scala - How to transform an array to a string using mkString? Code Example
The code for How to transform an array to a string using mkString?
val arr = Array(10,20,30)
var result = arr.mkString
println(result)
result = arr.mkString(",")
println(result)
result = arr.mkString(" ")
println(result)
result = arr.mkString("(", ",", ")")
println(result)
/*
Output:
102030
10,20,30
10 20 30
(10,20,30)
*/
Code by IncludeHelp,
on August 11, 2022 00:00