java.lang.String-firstMethod-charAt()

来源:互联网 发布:剑灵灵剑士捏脸数据 编辑:程序博客网 时间:2024/05/20 11:27

english prototype---

 

charAt

public char charAt(int index)
Returns the char value at the specified index. An index ranges from 0 to length() - 1. The first char value of the sequence is at index 0, the next at index 1, 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 interface CharSequence
Parameters:
index - the index of the char value.
Returns:
the char value at the specified index of this string. The first char value is at index 0.
Throws:
IndexOutOfBoundsException - if the index 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(数组下标越界),如果索引是一个负数或者小于这个字符串的长度,就会抛出这个异常。

原创粉丝点击