Here you can find the source of hashCode(Object value)
Parameter | Description |
---|---|
value | the object to get hash code for. |
public static int hashCode(Object value)
//package com.java2s; /*//from w ww . ja v a2 s .co m * Copyright 2008-2012 Ruslan Khmelyuk. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ public class Main { /** * Returns the hash code of object. If object is equal {@code null} then 0 is returned. * * @param value the object to get hash code for. * @return the hash code of value. */ public static int hashCode(Object value) { if (value != null) { return value.hashCode(); } return 0; } /** * Returns the hash code of objects. If any object is equal {@code null} then 0 is returned. * * @param values the objects to get hash code for. * @return the hash code of value. * * @since 1.0.2 */ public static int hashCode(Object... values) { if (values == null) return 0; int result = 0; for (Object each : values) { result += hashCode(each); } return result ^ 31; } }