
上QQ阅读APP看书,第一时间看更新
There’s more...
String templates also come in handy with String properties and functions. Here's an example:
fun main(args: Array<String>) {
val str1="abcdefghijklmnopqrs"
val str2="tuvwxyz"
println("str1 equals str2 ? = ${str1.equals(str2)}")
println("subsequence is ${str1.subSequence(1,4)}")
println("2nd character is ${str1.get(1)}")
}
Here's the output:
str1 equals str2 ? = false
subsequence is bcd
2nd character is b