Here you can find the source of hashCode(Object array)
Parameter | Description |
---|---|
array | must be an array of any type or null |
static int hashCode(Object array)
//package com.java2s; import java.util.Arrays; public class Main { /**/*from w ww. ja v a2 s . c om*/ * Hashes an array. Provides a deep hash code in the case of an object array that contains other arrays. * * @param array must be an array of any type or {@code null} * @return hashCode */ static int hashCode(Object array) { int hashCode; if (array == null) { hashCode = 0; } else if (array instanceof byte[]) { hashCode = Arrays.hashCode((byte[]) array); } else if (array instanceof short[]) { hashCode = Arrays.hashCode((short[]) array); } else if (array instanceof int[]) { hashCode = Arrays.hashCode((int[]) array); } else if (array instanceof long[]) { hashCode = Arrays.hashCode((long[]) array); } else if (array instanceof float[]) { hashCode = Arrays.hashCode((float[]) array); } else if (array instanceof double[]) { hashCode = Arrays.hashCode((double[]) array); } else if (array instanceof boolean[]) { hashCode = Arrays.hashCode((boolean[]) array); } else if (array instanceof char[]) { hashCode = Arrays.hashCode((char[]) array); } //This is true if array is any non-primitive array else if (array instanceof Object[]) { hashCode = Arrays.hashCode((Object[]) array); } else { throw new IllegalArgumentException( "value provided is not array, class: " + array.getClass().getCanonicalName()); } return hashCode; } }