While the MessageDigest
class always provided an isEqual()
method to compare two byte
arrays, it never felt right
to use it to compare byte
arrays unless they were from
message digests. Now, with the help of the Arrays
class,
you can check for equality of any array of primitive or object
type. Two arrays are equal if they contain the same elements in
the same order. Checking for equality with arrays of objects
relies on the equals()
method of each object to check
for equality.
byte array1[] = ...;
byte array2[] = ...;
if (Arrays.equals(array1, array2) {
// They're equal
}