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

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.