Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: wrong behaviour when checking the equality of two elements of an ArrayList<Integer> using the operator "=="



Is the fact that == returns true a problem, or simply a curiosity? If it's
a problem, please explain how it's a problem.

It was mostly a curiosity. I had made a comparison with different JVMs on Linux and I didn't get the same result.
In my mind I was always comparing two different objects and therefore I didn't understand why the result of the comparison (done with ==) was true. In general when comparing Integer objects for equality I will use the Integer.equals() method and not the == operator.


Thanks to all for the detailed answers. This has been most illuminating.
Cheers,
Francesca
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden
References: 
 >Re: wrong behaviour when checking the equality of two elements of an ArrayList<Integer> using the operator "==" (From: Greg Guerin <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.