Name
String
Synopsis
This class represents a immutable character string. Operations on
String objects that change their content actually
place their results in other String objects.
When concatenating strings or changing the values of characters within
a string, it is more efficient to use a StringBuffer
instead.
The CLDC String class is similar to its J2SE equivalent,
but lacks the following methods: compareToIgnoreCase(),
copyValueOf(), equalsIgnoreCase() and
intern(). It also does not contain the variants of
lastIndexOf() that accept a String-
valued argument, or the valueOf() methods for
types float and double.
A String can be constructed as a copy of another
String, from the content of a
StringBuffer, or from an array of characters or bytes.
When constructing a String from bytes, the appropriate
character encoding must be used; if an encoding is not specified, the
platform’s default encoding is assumed. A String can
also be created by applying the static valueOf() methods
to a boolean, a char, an array of
characters (char[]), an int, a
long or an arbitrary Java Object.
With an Object, the String is
created using the return value of the object’s toString()
method.
The toCharArray() method returns an array of
chars initialized with the content of the
String. The getChars() method is
similar, but requires the caller to allocate the destination array and can be
used to extract a subset of the string. The getBytes()
methods copy a subset of the String into a pre-allocated byte ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access