In Kotlin, the String class represents character strings.
Table of Contents
Access characters of a String
Index access operator can be used.
val str = "abCdEf"
str[2] //"C"
Iterate through a String
for (c in str) {
println(c)
}
Add leading zeros to a number
Method padStart() of the CharSequence class can add any characters to the beginning of a string/char sequence.
val padWithZeros = "1".padStart(2, '0')
//output: "01"