Pair { @Override public int hashCode() { int result = key == null ? 0 : key.hashCode(); final int h = value == null ? 0 : value.hashCode(); result = 37 * result + h ^ (h >>> 16); return result; } Pair(K k, V v);  Pair(Pair<? extends K, ? extends V> entry); K getKey(); V getValue(); K getFirst(); V getSecond(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); static Pair<K, V> create(K k, V v);  }
@Test public void testHashCode() { final MyInteger m1 = new MyInteger(1); final MyInteger m2 = new MyInteger(1); final Pair<MyInteger, MyInteger> p1 = new Pair<MyInteger, MyInteger>(m1, m1); final Pair<MyInteger, MyInteger> p2 = new Pair<MyInteger, MyInteger>(m2, m2); Assert.assertTrue(p1.hashCode() == p2.hashCode()); m2.set(2); Assert.assertFalse(p1.hashCode() == p2.hashCode()); }