Name
CharSequence
Synopsis
This
interface defines a simple API for read-only access to sequences of
characters. In the core platform it is implemented by the
String
, StringBuffer
and
java.nio.CharBuffer
classes. charAt(
)
returns the character at a specified position in the sequence.
length( )
returns the number of characters in the sequence.
subSequence( )
returns a CharSequence
that consists of the
characters starting at, and including, the specified
start
index, and continuing up to, but not
including the specified end
index.
Finally, toString( )
returns a String
version of the sequence.
Note that CharSequence
implementations do not
typically have interoperable equals( )
or
hashCode( )
methods, and it is not usually
possible to compare two CharSequence
objects or
use multiple sequences in a set or hashtable unless they are
instances of the same implementing class.
public interface CharSequence { // Public Instance Methods char charAt(int index); int length( ); CharSequence subSequence(int start, int end); String toString( ); }
Implementations
String
, StringBuffer
,
StringBuilder
,
java.nio.CharBuffer
Passed To
Too many methods to list.
Returned By
String.subSequence( )
,
StringBuffer.subSequence( )
,
java.nio.CharBuffer.subSequence( )
Get Java in a Nutshell, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.