posted 21 years ago
There is no way to tell from a hash code what type an object is or what its value(s) is/are.
Well, there is a way to reconstruct a String value from its hashcode, but it's very ugly and not reliable. The only purpose of doing it may be as an exercise to see how the hashCode() works in a particular JDK implementation, or to have it formulated as a pure and theoretical math problem. So, while the reconstruction code below works, don't use it, -- for all intents and purposes, the street from an object to its hash code is a one way street, just like Joe indicated.
Output:
original string is cat
reconstructed string is cat
[ October 06, 2003: Message edited by: Eugene Kononov ]