Here you can find the source of hashCode(Object obj)
Gets the hash code of an object returning zero when the object is null
.
ObjectUtils.hashCode(null) = 0 ObjectUtils.hashCode(obj) = obj.hashCode()
Parameter | Description |
---|---|
obj | the object to obtain the hash code of, may be <code>null</code> |
public static int hashCode(Object obj)
//package com.java2s; public class Main { /**// w ww . j av a2 s . c o m * <p>Gets the hash code of an object returning zero when the * object is <code>null</code>.</p> * * <pre> * ObjectUtils.hashCode(null) = 0 * ObjectUtils.hashCode(obj) = obj.hashCode() * </pre> * * @param obj the object to obtain the hash code of, may be <code>null</code> * @return the hash code of the object, or zero if null * @since 2.1 */ public static int hashCode(Object obj) { return (obj == null) ? 0 : obj.hashCode(); } }