Array Equality
We now examine the meaning of equality between two arrays and learn how to test for it.
We'll cover the following...
The meaning of array equality
If we have two distinct arrays, what does it mean to say that the arrays are equal? Arrays are equal when their corresponding entries are equal. For example, the following two arrays are equal:
String[] names = {"alpha", "beta", "gamma", "delta"};
String[] tags = {"alpha", "beta", "gamma", "delta"};
The arrays have the same length, and the strings in corresponding elements are equal in value. That is, names[index]
equals tags[index]
as index
ranges in value from 0 to 3. Since the arrays contain strings, we could test the equality of these entries by evaluating the Boolean expression
...
Access this course and 1400+ top-rated courses and projects.