Calling toString() on an array returns the address of the object in memory, not a string representation of the array's contents. This is almost never what you want.

To get a string representation of an array correctly, use:

Example (explicit toString):


  fun main() {
      val a = arrayOf(1, 2, 3)
      val s = a.toString() // incorrect
  }

After the quick-fix is applied:


  fun main() {
      val a = arrayOf(1, 2, 3)
      val s = a.contentToString() // correct
  }

Example (implicit toString in string template):


  fun main() {
      val a = arrayOf(1, 2, 3)
      println("Array: $a") // incorrect - prints address
  }

After the quick-fix is applied:


  fun main() {
      val a = arrayOf(1, 2, 3)
      println("Array: ${a.contentToString()}") // correct - prints [1, 2, 3]
  }

Example (multidimensional array):


  fun main() {
      val a2d = arrayOf(arrayOf(1, 2), arrayOf(3, 4))
      val s = a2d.toString() // incorrect
  }

After the quick-fix is applied:


  fun main() {
      val a2d = arrayOf(arrayOf(1, 2), arrayOf(3, 4))
      val s = a2d.contentDeepToString() // correct - prints [[1, 2], [3, 4]]
  }