Here you can find the source of hashCode(final int i)
Parameter | Description |
---|---|
i | The integer value |
i
public static final int hashCode(final int i)
//package com.java2s; /******************************************************************************* * Copyright (c) 2013, 2015 IBM Corporation and others. * 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:/*from www .j a v a2s . c o m*/ * IBM Corporation - initial API and implementation *******************************************************************************/ public class Main { /** * Provides a hash code based on the given integer value. * * @param i * The integer value * @return <code>i</code> */ public static final int hashCode(final int i) { return i; } /** * Provides a hash code for the object -- defending against <code>null</code>. * * @param object * The object for which a hash code is required. * @return <code>object.hashCode</code> or <code>0</code> if <code>object</code> if * <code>null</code>. */ public static final int hashCode(final Object object) { return object != null ? object.hashCode() : 0; } /** * Computes the hash code for an array of objects, but with defense against <code>null</code>. * * @param objects * The array of objects for which a hash code is needed; may be <code>null</code>. * @return The hash code for <code>objects</code>; or <code>0</code> if <code>objects</code> is * <code>null</code>. */ public static final int hashCode(final Object[] objects) { if (objects == null) { return 0; } int hashCode = 89; for (int i = 0; i < objects.length; i++) { final Object object = objects[i]; if (object != null) { hashCode = hashCode * 31 + object.hashCode(); } } return hashCode; } }