Range { @Override public int hashCode() { return 31 * this.lower + this.upper; } Range();  Range(int lower, int upper);  Range(Range range); @Override boolean equals(Object o); @Override int hashCode(); int length(); Range set(int lower, int upper); Range set(Range range); Range setEmpty(); boolean isEmpty(); public int lower; public int upper; }
@Test public void testHashCode() throws Exception { Range range1 = new Range(1, 2); Range range2 = new Range(range1); Range range3 = new Range(2, 1); int hashCode1 = range1.hashCode(); int hashCode2 = range2.hashCode(); int hashCode3 = range3.hashCode(); assertEquals(hashCode1, hashCode2); assertNotEquals(hashCode1, hashCode3); }