Short answer: no. Long answer, maybe. ;>
It depends on how you write the object. For instance, consider the
class
class UniqueHash {
static int id = 0;
int hashCode = id++;
public int hashCode() {
return hashCode;
}
}
Objects instantiated from this class are guaranteed to have unique hash
codes, and so the following will be true for all instances of a and b:
UniqueHash a,b;
//...
a.equals(b) == (a.hashCode() == b.hashCode());
And indeed, you could replace the a.equals(b) with a == b for the same
results.
Typically, though, such behavior is undesirable and even dangerous.
hashCode and equals do different things. It sounds like you need not
an array but a HashMap, which isn't significantly slower than an array
anyhow.
Walter Gildersleeve
Freiburg, Germany
______________________________________________________
http://linkfrog.net
URL Shortening
Free and easy, small and green.