Java中的charAt()方法
charAt()方法用于返回指定索引处的字符,索引范围:0~length()-1
语法
public char charAt(int index)
参数
· index--字符的索引
返回值
指定索引处的字符
实例
public class Test {
public static void main(String args[]) {
String s = "www.baiducom";
char result = s.charAt(6);
System.out.println(result);
}
}
执行结果:
i