Java.lang.Long.hashCode() 方法
描述
java.lang.Long.hashCode() 方法返回此 Long 的哈希码。 结果是此 Long 对象持有的原始 long 值的两半的异或。
声明
以下是 java.lang.Long.hashCode() 方法的声明。
public int hashCode()
参数
NA
返回值
此方法返回此对象的哈希码值。
异常
NA
示例
下面的例子展示了 java.lang.Long.hashCode() 方法的使用。
package com.tutorialspoint;
import java.lang.*;
public class LongDemo {
public static void main(String[] args) {
Long l = new Long(65987);
/* returns a hash code value for this object, equal to the primitive
int value represented by this Long object */
int retval = l.hashCode();
System.out.println("Value = " + retval);
}
}
让我们编译并运行上面的程序,这将产生下面的结果 −
Value = 65987

