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

被折叠的 条评论
为什么被折叠?



