Here you can find the source of hashCode(long longVal)
Parameter | Description |
---|---|
longVal | value for which to compute hashCode |
public static int hashCode(long longVal)
//package com.java2s; public class Main { /**// w w w. j a va 2s . com * Get standard Java hashCode for a long without the extra object creation. * * <p>Equivalent to (new Long(longVal)).hashCode() in jdk1.6.</p> * * @param longVal value for which to compute hashCode * @return hashCode */ public static int hashCode(long longVal) { // combine upper 32 and lower 32 bits via exclusive or return (int) (longVal ^ (longVal >>> 32)); } /** * Get standard Java hashCode for a float without the extra object creation. * * <p>Equivalent to (new Float(floatVal)).hashCode() in jdk1.6.</p> * * @param floatVal value for which to compute hashCode * @return hashCode */ public static int hashCode(float floatVal) { return Float.floatToIntBits(floatVal); } /** * Get standard Java hashCode for a float without the extra object creation. * * <p>Equivalent to (new Double(doubleVal)).hashCode() in jdk1.6.</p> * * @param doubleVal value for which to compute hashCode * @return hashCode */ public static int hashCode(double doubleVal) { return hashCode(Double.doubleToLongBits(doubleVal)); } /** * Get standard Java hashCode for a boolean without the extra object creation. * * <p>Equivalent to (new Boolean(booleanVal)).hashCode() in jdk1.6.</p> * * @param booleanVal value for which to compute hashCode * @return hashCode */ public static int hashCode(boolean booleanVal) { return (booleanVal ? 1231 : 1237); } }