Java String.format alternative in kotlin?



I’m using java String.format in my codes which i want to port to kotlin.
For example
String log = String.format("%d, %s, %6f : %3f", value1, value2, value3, value4)

How to convert above java code to kotlin?



You can use java String

fun main(args : Array<String>) {   var value1 = 1   var value2 = "2"   var value3 = 3.0   var value4 = 4.0   println(java.lang.String.format("%d, %s, %6f : %3f", value1, value2, value3, value4)) }


Thank you for your reply. It works.


You can also write

println("%d, %s, %6f : %3f".format(value1, value2, value3, value4))