please let me know the correct way using String.fo...
# announcements
a
please let me know the correct way using String.format in kotlin
Copy code
val tobeFormatted:String = "Please enter a password with at least %s characters."

     val stringParams = ArrayList<String>()
     stringParams.add("3")
      System.out.println(String.format(tobeFormatted,stringParams.toTypedArray()))
The output is
Copy code
Please enter a password with at least [3] characters.
it is taking whole array as argument * What i expect is like below *
Copy code
Please enter a password with at least 3 characters.
however in java the below code for string format works flawlessly
Copy code
String f = "Mi name is %s %s.";
System.out.println(String.format(f, new String[]{"John","Connor"}));