I want to trim a string if the length exceeds 10 characters.
Suppose if the string length is 12 (String s=\"abcdafghijkl\"), then the new trimmed string
String s=\"abcdafghijkl\"
With Kotlin it is as simple as:
yourString.take(10)
Returns a string containing the first n characters from this string, or the entire string if this string is shorter.
Documentation