The String Operators
The
String
class overloads two operators:
= =
and
!=
. To test two strings for equality, use the
= =
operator. Normally, when the
= =
operator is applied to object references, it determines
if both references refer to the same object. This differs for objects of type
String
. When the
= =
is applied to two
String
references, the contents of the strings, themselves, are compared
for equality. The same is true for the
!=
operator: When comparing
String
objects, the contents
of the strings are compared. However, the other relational operators, such as
<
or
>=
, compare
the references, just like they do for other types of objects. To determine if one string is greater
than or less than another, use the
Do'stlaringiz bilan baham: |