Actually, it works the same for both Objects and primitive types.
The == operator checks if the value held by both variables is the
same.
For primitive types (e.g. int), this value is a 32-bit value (or 64-
bit for long, etc).
For Objects, this value is the *reference* to an object, not the
object itself.
E.g
String string1 = new String("hello");
String string2 = new String("hello");
boolean stringsEqual = (string1 == string2);
stringsEqual is false in this case, because string1 refers to a
different object than string2 (the value of the string1/string2 is the
*reference* to its Object).
If the variables are not primitive, the == operator returns true only
if both variables refer to the same object/instance.
On Jun 29, 3:26 pm, Frank Weiss <[email protected]> wrote:
> Further clarification: in Java the == operator works differently for
> primitive types (int, double, etc.) than for Objects (such as String).
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en