Groovy - getAt()
返回数组对应索引的字符串内容
语法
String getAt(int index)
参数
- Index – 要返回的字符串的位置
返回值
索引位置的字符串值
示例
以下是该方法的用法示例 −
class Example {
static void main(String[] args) {
String a = "Hello World";
println(a.getAt(2));
println(a.getAt(6));
println(a.getAt(7));
}
}
当我们运行上面的程序时,会得到下面的结果 −
l W O