Here you can find the source of hashCode(final Object... objects)
Parameter | Description |
---|---|
objects | the objects used to construct the hashcode (can contain <code>null</code> objects) |
public static final int hashCode(final Object... objects)
//package com.java2s; /*/*w ww . j ava 2 s . c om*/ * JBoss, Home of Professional Open Source. * * See the LEGAL.txt file distributed with this work for information regarding copyright ownership and licensing. * * See the AUTHORS.txt file distributed with this work for a full listing of individual contributors. */ import java.util.Arrays; public class Main { /** * Used when calculating hashcodes. * * @see #hashCode(Object...) */ private static final int PRIME = 103; /** * Compute a combined hash code from the supplied objects. This method always returns 0 if no objects are supplied. * * @param objects the objects used to construct the hashcode (can contain <code>null</code> objects) * @return the hashcode */ public static final int hashCode(final Object... objects) { if ((objects == null) || (objects.length == 0)) { return 0; } // Compute the hash code for all of the objects ... int hc = 0; for (Object object : objects) { hc = PRIME * hc; if (object instanceof byte[]) { hc += Arrays.hashCode((byte[]) object); } else if (object instanceof boolean[]) { hc += Arrays.hashCode((boolean[]) object); } else if (object instanceof short[]) { hc += Arrays.hashCode((short[]) object); } else if (object instanceof int[]) { hc += Arrays.hashCode((int[]) object); } else if (object instanceof long[]) { hc += Arrays.hashCode((long[]) object); } else if (object instanceof float[]) { hc += Arrays.hashCode((float[]) object); } else if (object instanceof double[]) { hc += Arrays.hashCode((double[]) object); } else if (object instanceof char[]) { hc += Arrays.hashCode((char[]) object); } else if (object instanceof Object[]) { hc += Arrays.hashCode((Object[]) object); } else if (object != null) { hc += object.hashCode(); } } return hc; } }