@Test public void testPair() { String first = "abcdef"; Long second = 23L; Pair<String, Long> pairOne = new Pair<>(first, second); Pair<String, Long> pairTwo = new Pair<>(first, second); Pair<String, Long> pairThree = new Pair<>(first, second + 1); Pair<String, Long> pairFour = new Pair<>(first + "extra", second); Pair<Long, String> pairFive = new Pair<>(second, first); assertEquals("Invalid first item.", first, pairOne.getFirst()); assertEquals("Invalid second item.", second, pairOne.getSecond()); assertEquals("These pairs should be equivalent", pairTwo, pairOne); assertFalse("pairOne and pairThree should not be equal", pairOne.equals(pairThree)); assertFalse("pairOne and pairFour should not be equal", pairOne.equals(pairFour)); assertFalse("pairOne and pairFive should not be equal", pairOne.equals(pairFive)); assertEquals("Hashcodes should be the same", pairOne.hashCode(), pairTwo.hashCode()); assertEquals("Pair{first=" + first + ", second=" + second + "}", pairOne.toString()); }
public Pair(A first, B second) { this.first = first; this.second = second; }
Pair { public Pair(A first, B second) { this.first = first; this.second = second; } }
Pair { public Pair(A first, B second) { this.first = first; this.second = second; } Pair(A first, B second); }
Pair { public Pair(A first, B second) { this.first = first; this.second = second; } Pair(A first, B second); A getFirst(); B getSecond(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); }
Pair { public Pair(A first, B second) { this.first = first; this.second = second; } Pair(A first, B second); A getFirst(); B getSecond(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode();  }