Originally posted by megha joshi:
Strangely...that does not happen when I use
System.out.println(l1[0].equals(l2[0]));
This gives false.
Can someone explain why the RULES are so easy!!!
[ April 29, 2007: Message edited by: megha joshi ]
That code is different from the earlier code.
In the earlier code, a primitive was being compared to a wrapper. In that case, the wrapper was unboxed.
I'm not exactly sure where you are getting l1 and l2 from, but if they refer to an array of Longs and an array of Integers, then the equals method will necessarily return false.
This is from the API docs for Long. But the same idea will apply for Integer.
Compares this object to the specified object. The result is true if and only if the argument is not null and is a Long object that contains the same long value as this object.