previous | start | next

A hashCode method for the Coin class

class Coin
{
   public int hashCode()
   {
      int h1 = name.hashCode();
      int h2 = new Double(value).hashCode();
      final int HASH_MULTIPLIER = 29;
      int h = HASH_MULTIPLIER * h1 + h2:
      return h
   }
   . . .
}


previous | start | next