Here you can find the source of hashCode(boolean bool)
Boolean#hashCode()
.
Parameter | Description |
---|---|
bool | boolean |
public static int hashCode(boolean bool)
//package com.java2s; /******************************************************************************* * Copyright (c) 2008, 2010 VMware Inc.//from w w w. j a v a2s. c o m * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * VMware Inc. - initial contribution *******************************************************************************/ public class Main { /** * Return the same value as <code>{@link Boolean#hashCode()}</code>. * @param bool boolean * @return hash code * @see Boolean#hashCode() */ public static int hashCode(boolean bool) { return bool ? 1231 : 1237; } /** * Return the same value as <code>{@link Double#hashCode()}</code>. * @param dbl double * @return hash code * @see Double#hashCode() */ public static int hashCode(double dbl) { long bits = Double.doubleToLongBits(dbl); return hashCode(bits); } /** * Return the same value as <code>{@link Float#hashCode()}</code>. * @param flt float * @see Float#hashCode() * @return hash code */ public static int hashCode(float flt) { return Float.floatToIntBits(flt); } /** * Return the same value as <code>{@link Long#hashCode()}</code>. * @param lng long * @see Long#hashCode() * @return hash code */ public static int hashCode(long lng) { return (int) (lng ^ (lng >>> 32)); } }