/**
- Created by caoxiaohong on 17/11/18 23:18.
*/
import java.lang.*;
/**
public interface CharSequence {
/**
- Returns the length of this character sequence. The length is the number
- of 16-bit
char s in the sequence.
-
- 返回字符序列的长度.
- 长度是16bit的整数倍.(因为String类采用的是UTF-16编码,一个字符占用2个字节长度)
-
- @return the number of
char s in this sequence
*/
int length();
/**
* Returns the <code>char</code> value at the specified index. An index ranges from zero
* to <tt>length() - 1</tt>. The first <code>char</code> value of the sequence is at
* index zero,the next at index one,and so on,as for array
* indexing. </p>
*
* 返回指定索引index位置处的字符.索引index的范围是[0,length()-1].
*
* <p>If the <code>char</code> value specified by the index is a
* <a href="{@docRoot}/java/lang/Character.html#unicode">surrogate</a>,the surrogate
* value is returned.
*
* 如果指定索引位置处的字符值为代表(字符)(surrogate的出现原因:因为UTF-16采用2个字节存储一个字符,但是有的字符存储只需要一个字节,比如英文
* 字符,那么下一个字节也不能继续存储其他的字符,而只能存储一个代表字符,来占用这一个字节的位置,接下来的一个字节处才能继续存储下一个字符),* 那么返回的也会是这个代表(字符)值.
*
* @param index the index of the <code>char</code> value to be returned
*
* @return the specified <code>char</code> value
*
* @throws IndexOutOfBoundsException
* if the <tt>index</tt> argument is negative or not less than
* <tt>length()</tt>
*/
char charAt(int index);
/**
* Returns a new <code>CharSequence</code> that is a subsequence of this sequence.
* The subsequence starts with the <code>char</code> value at the specified index and
* ends with the <code>char</code> value at index <tt>end - 1</tt>. The length
* (in <code>char</code>s) of the
* returned sequence is <tt>end - start</tt>,so if <tt>start == end</tt>
* then an empty sequence is returned. </p>
*
* 返回一个新的字符序列,这个序列是原字符序列的子序列.
* 子序列的截取开始位置为:原序列中start的位置;
* 截取结束位置为:原序列中(end-1)的位置.
* 因此子字符序列的长度为(end-start)
* 所以,如果传入参数start=end,则返回子序列为空序列.
*
* @param start the start index,inclusive
* @param end the end index,exclusive
*
* @return the specified subsequence
*
* @throws IndexOutOfBoundsException
* if <tt>start</tt> or <tt>end</tt> are negative,* if <tt>end</tt> is greater than <tt>length()</tt>,* or if <tt>start</tt> is greater than <tt>end</tt>
*/
CharSequence subSequence(int start,int end);
/**
* Returns a string containing the characters in this sequence in the same
* order as this sequence. The length of the string will be the length of
* this sequence. </p>
*
* 返回字符序列的字符串形式,字符串中字符的顺序和字符序列保持一致.字符串的长度和字符序列一致.
*
* @return a string consisting of exactly this sequence of characters
*/
public java.lang.String toString();
}
(编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|