How to print all elements of String array in Kotlin in a single line?

Idiomatically:

fun main(args: Array<String>) {
  val someList = arrayOf("United", "Chelsea", "Liverpool")
  println(someList.joinToString(" "))
}

This makes use of type inference, an immutable value, and well-defined methods for doing well-defined tasks.

The joinToString() method also allows prefix and suffix to be included, a limit, and truncation indicator.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)