-
Notifications
You must be signed in to change notification settings - Fork 22
Collections: Converting a list array to string
Devrath edited this page Feb 29, 2024
·
1 revision
code
val input = arrayOf("USA", "Australia", "USA", "Russia", "Russia", "England")
fun main(args: Array<String>) {
println("<-Just Combine-> ${input.joinToString()}")
println("<-Combine with separator-> ${input.joinToString(separator = "-")}")
println("<-Combine with prefix and postfix-> ${input.joinToString(prefix = "INITIAL<>", separator = "-", postfix = "<>FINAL")}")
}
output
<-Just Combine-> USA, Australia, USA, Russia, Russia, England
<-Combine with separator-> USA-Australia-USA-Russia-Russia-England
<-Combine with prefix and postfix-> INITIAL<>USA-Australia-USA-Russia-Russia-England<>FINAL