Not able to print an Array which is nested inside a list using the toString utility.
In which step of the codelab can this issue be found?
Step number 5 .
Steps to reproduce?
In the Codelab, we were instructed that to print an Array declared using arrayOf we must use the java.util.Arrays.toString() utility.
So, if we declare this:
val numbers = intArrayOf(1,2,3)
And, if we try to print it like so:
println(java.util.Arrays.toString(numbers))
it works.
But if we try to create a nested list with an Array and a String or something else then we can not print the Array
Like so:
val numbers = intArrayOf(1, 2, 3)
val oceans = listOf("Atlantic", "Pacific")
val oddList = listOf(numbers, oceans, "salmon")
println(java.util.Arrays.toString(oddList[0]))
It gives this error:
None of the following functions can be called with the arguments supplied: public open fun toString(p0: Array<(out) Any!>!): String! defined in java.util.Arrays public open fun toString(p0: BooleanArray!): String! defined in java.util.Arrays public open fun toString(p0: ByteArray!): String! defined in java.util.Arrays public open fun toString(p0: CharArray!): String! defined in java.util.Arrays public open fun toString(p0: DoubleArray!): String! defined in java.util.Arrays public open fun toString(p0: FloatArray!): String! defined in java.util.Arrays public open fun toString(p0: IntArray!): String! defined in java.util.Arrays public open fun toString(p0: LongArray!): String! defined in java.util.Arrays public open fun toString(p0: ShortArray!): String! defined in java.util.Arrays
Versions
What version of IntelliJ IDEA are you using?
I tried that on the Kotlin's website it self. In the Try Kotlin Section
Additional information
If we could get some information on how Arrays and Lists worked in the memory, that would help a lot. Thank you.
Describe the problem
Not able to print an Array which is nested inside a list using the toString utility.
In which step of the codelab can this issue be found?
Step number 5 .
Steps to reproduce?
In the Codelab, we were instructed that to print an Array declared using arrayOf we must use the
java.util.Arrays.toString()
utility.So, if we declare this:
val numbers = intArrayOf(1,2,3)
And, if we try to print it like so:
println(java.util.Arrays.toString(numbers))
it works.
But if we try to create a nested list with an Array and a String or something else then we can not print the Array
Like so:
It gives this error:
Versions What version of IntelliJ IDEA are you using? I tried that on the Kotlin's website it self. In the Try Kotlin Section
Additional information If we could get some information on how Arrays and Lists worked in the memory, that would help a lot. Thank you.
codelab: kotlin-bootcamp