Java Hash Code Calculate hashCode(boolean value)

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

Description

Returns hash code for a boolean value.

License

Open Source License

Return

the integer 1231 if this value is true; returns the integer 1237 if value is false. These numbers are taken from Boolean.hashCode() implementation.

Declaration

public static int hashCode(boolean value) 

Method Source Code

//package com.java2s;
/*// www . j  a  v  a  2 s .c  o  m
* Copyright (c) 2000 - 2005 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  
*
*/

public class Main {
    /**
     * Returns hash code for a <code>boolean</code> value.
     *
     * @return  the integer <tt>1231</tt> if this value is
     * <tt>true</tt>; returns the integer <tt>1237</tt> if
     * value is <tt>false</tt>. These numbers are taken from
     * <code>Boolean.hashCode()</code> implementation.
     */
    public static int hashCode(boolean value) {
        return (value ? 1231 : 1237);
    }

    /**
     * Returns hash code for the specified object or zero of the object
     * is <code>null</code>.
     *
     * @return  zero if <code>value</code> is <code>null</code>, otherwise
     *          the value returned by <code>value.hashCode()</code>.
     */
    public static int hashCode(Object obj) {
        return ((obj == null) ? 0 : obj.hashCode());
    }
}

Related

  1. generateHashUUID(String digestData)
  2. hashCode(boolean b)
  3. hashCode(boolean b)
  4. hashCode(boolean bool)
  5. hashCode(boolean bool)
  6. hashCode(byte a[])
  7. hashCode(byte a[], int offset, int length)
  8. hashCode(byte[] array)
  9. hashCode(byte[] array, int size)