Java Reference
In-Depth Information
ters, which can represent any foreign character within the Basic Multilingual Plane
(BMP). However. Unicode 5.1 now contains over 100,000 characters, and so Java
only supports the most commonly used character sets. This is in contrast to COBOL
characters, which are only 8-bit, based on a particular code page (typically ASCII,
EBCDIC, or UTF-8). The developer can create a
String
object using the standard
Java syntax. You should be familiar with this construct, since you have used it sev-
eral times already.
String
provides an alternative constructor that accepts a
String
parameter.
This statement will set the
localText String
reference equal to a
String
that
contains “Some Text.”
This complete syntax is often compressed into the following form:
Notice that the compressed syntax is very similar to the syntax used to define
primitive data types:
int localInt = 1;
Despite the similarity in syntax, there is a major difference in the examples.
localInt
is a primitive data type, not an object. In contrast,
localText
is an object,
since all
String
s are objects.