english prototype---
charAt
public char charAt(int index)
-
Returns the
char
value at the specified index. An index ranges from0
tolength() - 1
. The firstchar
value of the sequence is at index0
, the next at index1
, and so on, as for array indexing.If the
char
value specified by the index is a surrogate, the surrogate value is returned. -
-
Specified by:
-
charAt
in interfaceCharSequence
-
-
-
Parameters:
-
index
- the index of thechar
value.
Returns:
-
the
char
value at the specified index of this string. The firstchar
value is at index0
.
Throws:
-
IndexOutOfBoundsException
- if theindex
argument is negative or not less than the length of this string.
-
中文--
public char charAt(int index)charAt() //一般我们看API的时候我们要关注这个方法名,返回类型,以及参数等几个方面,
返回特定索引上的一个char值,索引的范围是:0-字符串长度减一,第一个char的下标索引值是0,下一个是1,和数组时相类似的,如果char的值被特殊的索引替代,则这个替代的值就会被返回去。
charAt存在于接口CharSequence中,
参数:
索引-就是指的那个char的值
抛个异常:
跑出一个IndexOutOfBoundsException(数组下标越界),如果索引是一个负数或者小于这个字符串的长度,就会抛出这个异常。