in Java 7 we have
o.hashCode();
Objects.hashCode(o);
Objects.hash(o);
The first 2 are roughly the same with the null point check, but what is last one?
When a single object reference is supplied, the returned value does
not equal the hash code of that object reference.
Why is that? I mean, we don't need 3 methods that do the same thing, I understand that, but why do we need Objects.hash()
at all? When would you chose to use one vs another?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…