To convert a list of floats to a list of strings in Kotlin, you can use the map()
function to iterate over each float and convert it to a string using the toString()
method.
In this example,
floatList
.map()
function to iterate over each float in the list and convert it to a string using the toString()
method.fun main() {
val floatList = listOf(1.1f, 2.2f, 3.3f, 4.4f, 5.5f)
val stringList = floatList.map { it.toString() }
println("List of strings: $stringList")
}
List of strings: [1.1, 2.2, 3.3, 4.4, 5.5]
In this tutorial, we learned How to Convert a List of Floats to a List of Strings in Kotlin language with well detailed examples.