Java charAt() 方法

时间:2023-03-08 23:39:18
Java charAt() 方法

charAt() 方法用于返回指定索引处的字符。索引范围为从 0 到 length() - 1。

参数

  • index -- 字符的索引。

返回值

返回指定索引处的字符。

实例

public class Test {

    public static void main(String args[]) {
String s = "www.runoob.com";
char result = s.charAt(8);
System.out.println(result);
}
}