Java 教程 Java charAt() 方法

hubery · 2022-05-26 23:59:33 · 热度: 12

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

语法

public char charAt(int index)

参数

  • index -- 字符的索引。

返回值

返回指定索引处的字符。

实例

实例

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

以上程序执行结果为:

n

查看更多 Java String 类 相关内容

猜你喜欢:
暂无回复。
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册