Is there any reason that:
public void test(Object object) {
for (Object other : otherObjects) {
object.equals(other);
}
}
could be faster than:
public void test(Object object) {
for (Object other : otherObjects) {
other.equals(object);
}
}
( as equals()
is called on the same object in the first example?)
Related to Is CONSTANT.equals(VARIABLE) faster than VARIABLE.equals(CONSTANT)? and Interview : Java Equals.