目录

char charAt(int index)

描述 (Description)

此方法返回位于String指定索引处的字符。 字符串索引从零开始。

语法 (Syntax)

以下是此方法的语法 -

public char charAt(int index)

参数 (Parameters)

这是参数的细节 -

  • index - 要返回的字符的索引。

返回值 (Return Value)

  • 此方法返回指定索引处的char。

例子 (Example)

public class Test {
   public static void main(String args[]) {
      String s = "Strings are immutable";
      char result = s.charAt(8);
      System.out.println(result);
   }
}

这将产生以下结果 -

输出 (Output)

a
↑回到顶部↑
WIKI教程 @2018