Java charAt() 方法
charAt() 方法用于返回指定索引處的字符。索引范圍為從 0 到 length() - 1。
語法
public char charAt(int index)
參數
index -- 字符的索引。
返回值
返回指定索引處的字符。
實例
public class Test { public static void main(String args[]) { String s = "m.o2fo.com"; char result = s.charAt(8); System.out.println(result); } }
以上程序執(zhí)行結果為:
C
更多建議: