Here you can find the source of safeHashCode(Object o)
Parameter | Description |
---|---|
o | the object. |
public static int safeHashCode(Object o)
//package com.java2s; /*/*from w w w . ja v a 2 s. co m*/ * Copyright (c) 2013-2017 QuartzDesk.com. * Licensed under the MIT license (https://opensource.org/licenses/MIT). */ import java.util.Arrays; public class Main { /** * Returns the hash-code of the specified object. If the specified object * is null, then this method returns 1, rather then throwing NullPointerException. * * @param o the object. * @return the object's hash-code, or 1 if the object is null. */ public static int safeHashCode(Object o) { int hash = 1; if (o != null) { if (o.getClass().isArray()) return Arrays.deepHashCode((Object[]) o); else hash = o.hashCode(); } return hash; } }