Out of all the Java primitive types, the so-called integral types are the simplest to hash into integers. The integral data types are byte, short, int, long, and char. Since the underlying representation of such data types can be viewed as an integer, the hash function is trivial. A suitable function f for an integral data type is the identity function:
Program completes the definition of the Int wrapper class introduced in Program . In this case, the hashCode method simply returns the contents of the value field. Clearly, the running time of of the hashCode method is O(1).
Program: Int class hashCode method.