返回到:Java 介绍String类
charAt() 方法用于返回指定索引处的字符。索引范围为从 0 到 length() – 1。
语法
public char charAt(int index)
参数
- index — 字符的索引。
返回值
返回指定索引处的字符。
实例
public class Test {
public static void main(String args[]) {
String s = "www.w3cschool.cn";
char result = s.charAt(8);
System.out.println(result);
}
}
以上程序执行结果为:
C
返回到:Java 介绍String类
作者:terry,如若转载,请注明出处:https://www.web176.com/java_api/19504.html
支付宝
微信