Java-math-biginteger-hashcode
提供:Dev Guides
Java.math.BigInteger.hashCode()メソッド
説明
- java.math.BigInteger.hashCode()*は、このBigIntegerのハッシュコードを返します。
宣言
以下は* java.math.BigInteger.hashCode()*メソッドの宣言です。
public int hashCode()
オーバーライド
クラス Object のhashCode。
パラメーター
NA
戻り値
このメソッドは、このBigIntegerのハッシュコードを返します。
例外
NA
例
次の例は、math.BigInteger.hashCode()メソッドの使用法を示しています。
package com.finddevguides;
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