posted 17 years ago
That's because sometimes classes don't have a sophisticated equals implementation.
For instance, the equals method of Object just returns whether the two references point to the same object:
Programmers have to override the equals method to returns something more useful, like testing if the name or some other property is the same, or even multiple properties.
It seems however, that arrays just inherit Object's equals method, thereby checking only using ==. Like I said before, java.util.Arrays.equals(array1, array2) will check the entire contents of both arrays, doing what you need.
Well, until you pass an array of arrays, since the equals(Object[], Object[]) method uses equals for all elements of the arrays - if these are arrays themselves you still wind up with the same problem.