JAvaにおけるIntegerにおけるhashCodeメソッド
541 ワード
JAvaにおけるIntegerにおけるhashCodeメソッドは,書き換えられており,以下にIntegerクラスの実装の一部を写した.
実際には、Integerは簡単にtoStringとhashCodeの方法を書き直して、自分の値を返すことを見ることができます.
public String toString() {
return String.valueOf(value);
}
/**
* Returns a hash code for this Integer
.
*
* @return a hash code value for this object, equal to the
* primitive int
value represented by this
* Integer
object.
*/
public int hashCode() {
return value;
}
実際には、Integerは簡単にtoStringとhashCodeの方法を書き直して、自分の値を返すことを見ることができます.