Java Hash Code Calculate hashCode(Object value)

Here you can find the source of hashCode(Object value)

Description

Returns the hashcode of the specified value.

License

Open Source License

Declaration

public static final int hashCode(Object value) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*from   w ww . ja v a  2 s .com*/
     * Returns the hashcode of the specified value.
     */
    public static final int hashCode(Object value) {
        return (value == null) ? 0 : value.hashCode();
    }

    /**
     * Returns the hashcode of the specified value.
     */
    public static final int hashCode(int value) {
        return value;
    }

    /**
     * Returns the hashcode of the specified value.
     */
    public static final int hashCode(long value) {
        return (int) value;
    }

    /**
     * Returns the hashcode of the specified value.
     */
    public static final int hashCode(byte value) {
        return value;
    }

    /**
     * Returns the hashcode of the specified value.
     */
    public static final int hashCode(short value) {
        return value;
    }

    /**
     * Returns the hashcode of the specified value.
     */
    public static final int hashCode(char value) {
        return value;
    }

    /**
     * Returns the hashcode of the specified value.
     */
    public static final int hashCode(double value) {
        return (int) value;
    }

    /**
     * Returns the hashcode of the specified value.
     */
    public static final int hashCode(float value) {
        return (int) value;
    }

    /**
     * Returns the hashcode of the specified value.
     */
    public static final int hashCode(boolean value) {
        return value ? 1 : 0;
    }
}

Related

  1. hashCode(Object object)
  2. hashCode(Object objects[])
  3. hashCode(Object value)
  4. hashCode(Object value)
  5. hashCode(Object value)
  6. hashcode(Object... as)
  7. hashCode(Object... fields)
  8. hashCode(Object... objects)
  9. hashCode(Object... objects)