Scala学习之字符串篇(六):访问字符串特定位置的字符

在Scala中有如下几种方式来访问字符串中特定位置的字符。

scala> "hello".charAt(1)
res21: Char = e

scala> "hello"(1)
res22: Char = e

scala> "hello".apply(1)
res23: Char = e

评论

暂无评论