Here you can find the source of hashCode(Object o)
public static int hashCode(Object o)
//package com.java2s; /*/*from ww w . j a v a 2 s . c o m*/ * Copyright (c) 2007, 2011-2013, 2015, 2016 Eike Stepper (Berlin, Germany) 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: * Eike Stepper - initial API and implementation * Christian W. Damus (CEA LIST) - bug 418454 */ public class Main { public static int hashCode(Object o) { if (o == null) { return 0; } return o.hashCode(); } /** * A collision-free hash code for small sets (<=4) of small, positive integers (<=128) * * @since 3.2 */ public static int hashCode(int... values) { int hash = 0; for (int i = 0; i < values.length; i++) { hash += values[i]; hash = (hash << 7) - hash; } return hash; } public static int hashCode(long num) { return (int) (num >> 32) ^ (int) (num & 0xffffffff); } }