Package java.lang
Interface CharSequence
-
- All Known Implementing Classes:
CharBuffer,ICUResource.Key,String,StringBuffer,StringBuilder
public interface CharSequenceThis interface represents an ordered set of characters and defines the methods to probe them.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description charcharAt(int index)Returns the character atindex.intlength()Returns the number of characters in this sequence.CharSequencesubSequence(int start, int end)Returns aCharSequencefrom thestartindex (inclusive) to theendindex (exclusive) of this sequence.StringtoString()Returns a string with the same characters in the same order as in this sequence.
-
-
-
Method Detail
-
length
int length()
Returns the number of characters in this sequence.- Returns:
- the number of characters.
-
charAt
char charAt(int index)
Returns the character atindex.- Throws:
IndexOutOfBoundsException- ifindex < 0orindex >= length().
-
subSequence
CharSequence subSequence(int start, int end)
Returns aCharSequencefrom thestartindex (inclusive) to theendindex (exclusive) of this sequence.- Parameters:
start- the start offset of the sub-sequence. It is inclusive, that is, the index of the first character that is included in the sub-sequence.end- the end offset of the sub-sequence. It is exclusive, that is, the index of the first character after those that are included in the sub-sequence- Returns:
- the requested sub-sequence.
- Throws:
IndexOutOfBoundsException- ifstart < 0,end < 0,start > end, or ifstartorendare greater than the length of this sequence.
-
-