Interface CharSequence
- All Known Implementing Classes:
String, StringBuffer, StringBuilder
public interface CharSequence
This interface represents an ordered set of characters and defines the
methods to probe them.
-
Method Summary
Modifier and TypeMethodDescriptioncharcharAt(int index) Returns the character at the specified index, with the first character having index zero.default IntStreamchars()The sequence'scharvalues, zero-extended toint.default IntStreamThe sequence's code points.static intcompare(CharSequence cs1, CharSequence cs2) Compares two sequences lexicographically, char by char, the shorter first when one is a prefix of the other.default booleanisEmpty()Whether the sequence has no characters.intlength()Returns the number of characters in this sequence.subSequence(int start, int end) Returns aCharSequencefrom thestartindex (inclusive) to theendindex (exclusive) of this sequence.toString()Returns a string with the same characters in the same order as in this sequence.
-
Method Details
-
length
int length()Returns the number of characters in this sequence.
Returns
the number of characters.
-
charAt
char charAt(int index) Returns the character at the specified index, with the first character having index zero.
Parameters
index: the index of the character to return.
Returns
the requested character.
Throws
IndexOutOfBoundsException: @throws IndexOutOfBoundsException ifindex < 0orindexis greater than the length of this sequence.
-
subSequence
Returns a
CharSequencefrom thestartindex (inclusive) to theendindex (exclusive) of this sequence.Parameters
-
start: @param 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: @param 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: @throws IndexOutOfBoundsException ifstart end, or ifstartorendare greater than the length of this sequence.
-
-
toString
-
isEmpty
default boolean isEmpty()Whether the sequence has no characters. -
chars
The sequence'scharvalues, zero-extended toint. Stubbed in the CLDC11 subset; the implementation comes from the platform. -
codePoints
The sequence's code points. Stubbed in the CLDC11 subset. -
compare
Compares two sequences lexicographically, char by char, the shorter first when one is a prefix of the other.
-