Here you can find the source of hashCode(final Object obj)
Parameter | Description |
---|---|
obj | Object , if the object is array then the calculated hashcode is for every object in the array |
public static int hashCode(final Object obj)
//package com.java2s; //License from project: LGPL public class Main { /**/*from w w w . jav a 2s.co m*/ * Calculate hashcode of objects. This method calculate hashcode for every * instance in arrays. * * @param obj * {@link Object}, if the object is array then the calculated * hashcode is for every object in the array * @return calculated hashcode */ public static int hashCode(final Object obj) { if (obj == null) { return 0; } if (obj.getClass().isArray()) { Object[] array = (Object[]) obj; int result = 17; for (int i = 0; i < array.length; i++) { result = result * 37 + hashCode(array[i]); } return result; } return obj.hashCode(); } }