Here you can find the source of hashCode(Object a)
public static final int hashCode(Object a)
//package com.java2s; public class Main { /**//from w ww .j a v a2 s . c om * Get the hashCode of an object. * <p> * This method is just a shortcut to simplify assertion statements.</p> * @return an optimized version of a <span class="operator">==</span> <span class="keyword">null</span> <span class="operator">?</span> 0 <span class="operator">:</span> a.hashCode(). * @see #equals(Object, Object) */ public static final int hashCode(Object a) { try { return a.hashCode(); } catch (NullPointerException ex) { //@internal possibly quicker variant to explicit prechecks for null: simply let this exceptional case occur, and then handle it. if (a == null) { return 0; } else { // another cause for the NullPointerException than null arguments throw ex; } } } }