@Test public void testHashCodeWithSameObject() { final IntPair<String> p1 = new IntPair<String>(1, "first"); final IntPair<String> p2 = new IntPair<String>(1, "first"); int initial = p1.hashCode(); assertEquals(initial, p1.hashCode()); assertEquals(initial, p1.hashCode()); assertEquals(initial, p2.hashCode()); }
@Override public int hashCode() { int hash = 7; hash = 97 * hash + this.first; hash = 97 * hash + (this.second != null ? this.second.hashCode() : 0); return hash; }
IntPair { @Override public int hashCode() { int hash = 7; hash = 97 * hash + this.first; hash = 97 * hash + (this.second != null ? this.second.hashCode() : 0); return hash; } }
IntPair { @Override public int hashCode() { int hash = 7; hash = 97 * hash + this.first; hash = 97 * hash + (this.second != null ? this.second.hashCode() : 0); return hash; } IntPair(int first, T second); }
IntPair { @Override public int hashCode() { int hash = 7; hash = 97 * hash + this.first; hash = 97 * hash + (this.second != null ? this.second.hashCode() : 0); return hash; } IntPair(int first, T second); int getFirst(); T getSecond(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); }
IntPair { @Override public int hashCode() { int hash = 7; hash = 97 * hash + this.first; hash = 97 * hash + (this.second != null ? this.second.hashCode() : 0); return hash; } IntPair(int first, T second); int getFirst(); T getSecond(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }