- Java.math 包扩展
- Java.math - 枚举
- Java.math - 讨论
Java.math.BigInteger.hashCode() 方法
描述
java.math.BigInteger.hashCode() 返回此 BigInteger 的哈希代码。
声明
以下是 java.math.BigInteger.hashCode() 方法的声明。
public int hashCode()
重写
Object 类中的 hashCode。
参数
无
返回值
此方法返回此 BigInteger 的哈希代码。
异常
无
示例
以下示例展示了 math.BigInteger.hashCode() 方法的用法。
package com.tutorialspoint;
import java.math.*;
public class BigIntegerDemo {
public static void main(String[] args) {
// create 2 BigInteger objects
BigInteger bi1, bi2;
// create 2 int objects
int i1, i2;
// assign values to bi1, bi2
bi1 = new BigInteger("12345");
bi2 = new BigInteger("923456789123");
// assign the hashcode of bi1, bi2 to i1, i2
i1 = bi1.hashCode();
i2 = bi2.hashCode();
String str1 = "HashCode of " +bi1+ " is " +i1;
String str2 = "HashCode of " +bi2+ " is " +i2;
// print i1, i2 values
System.out.println( str1 );
System.out.println( str2 );
}
}
让我们编译并运行以上程序,这会产生以下结果 -
HashCode of 12345 is 12345 HashCode of 923456789123 is 38827148
java_math_biginteger.htm
广告