Java Reference
In-Depth Information
String
String
isthefirstpredefinedreferencetypepresentedinthisbook(in
Chapter1
).In-
stances of this type represent sequences of characters, or
strings.
Unlike other reference types, the Java language treats the
String
class specially,
byprovidingsyntacticsugarthatsimplifiesworkingwithstrings.Forexample,Javare-
cognizes
String favLanguage = "Java";
as the assignment of string literal
"Java"
to
String
variable
favLanguage
.Withoutthissugar,youwouldhaveto
specify
String favLanguage = new String("Java");
.TheJavalanguage
also overloads the
+
and
+=
operators to perform string concatenation.
String
objects and working with strings.