Here you can find the source of hashCode(Object obj)
obj
considering that obj
may be null.
Parameter | Description |
---|---|
obj | the obj to return the hashcode for |
public static int hashCode(Object obj)
//package com.java2s; //License from project: Apache License public class Main { /**/* ww w . j a va 2 s. co m*/ * Returns the hashcode of <code>obj</code> considering that <code>obj</code> may be <b>null</b>. * * @param obj the obj to return the hashcode for * @return the hashcode */ public static int hashCode(Object obj) { int result; if (null == obj) { result = 0; } else { result = obj.hashCode(); } return result; } /** * Returns the hash code of the given boolean. * * @param bool the boolean * @return the hash code */ static int hashCode(boolean bool) { return bool ? 1 : 0; } }