Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.

public interface CharSequence

Known subtypesString, StringBuffer, StringBuilder

This interface represents an ordered set of characters and defines the methods to probe them.

Methods

public abstract int length()Returns the number of characters in this sequence.
public abstract char charAt(int index)Returns the character at the specified index, with the first character having index zero.
public abstract CharSequence subSequence(int start, int end)Returns a CharSequence from the start index (inclusive) to the end index (exclusive) of this sequence.
public abstract String toString()Returns a string with the same characters in the same order as in this sequence.
public default boolean isEmpty()Whether the sequence has no characters.
public default IntStream chars()The sequence’s char values, zero-extended to int.
public default IntStream codePoints()The sequence’s code points.
public static int compare(CharSequence cs1, CharSequence cs2)Compares two sequences lexicographically, char by char, the shorter first when one is a prefix of the other.

Method details

length

public abstract int length()
Returns the number of characters in this sequence.

Returns

the number of characters.

charAt

public abstract char charAt(int index)
Returns the character at the specified index, with the first character having index zero.

Parameters

index int
the index of the character to return.

Returns

the requested character.

Throws

IndexOutOfBoundsException
if index < 0 or index is greater than the length of this sequence.

subSequence

public abstract CharSequence subSequence(int start, int end)
Returns a CharSequence from the start index (inclusive) to the end index (exclusive) of this sequence.

Parameters

start int
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 int
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
if start end, or if start or end are greater than the length of this sequence.

toString

public abstract String toString()
Returns a string with the same characters in the same order as in this sequence.

Returns

a string based on this sequence.

isEmpty

public default boolean isEmpty()
Whether the sequence has no characters.

chars

public default IntStream chars()
The sequence’s char values, zero-extended to int. Stubbed in the CLDC11 subset; the implementation comes from the platform.

codePoints

public default IntStream codePoints()
The sequence’s code points. Stubbed in the CLDC11 subset.

compare

public static int compare(CharSequence cs1, CharSequence cs2)
Compares two sequences lexicographically, char by char, the shorter first when one is a prefix of the other.