10. Fundamental Classes

10.1
 /** * Aggregate pairs of arbitrary objects. */ public final class Pair { private Object first, second; /** Construct a Pair object. */ public Pair(Object one, Object two) { first = one; second = two; } /** Provides access to the first aggregated object. */ public Object getFirst() { return first; } /** Provides access to the second aggregated object. */ public Object getSecond() { return second; } /** @return true if the pair of objects are identical. */ public boolean equals(Object other) { if (! (other instanceof Pair)) return false; Pair otherPair = (Pair) other; return first.equals(otherPair.getFirst()) && second.equals(otherPair.getSecond()); } /** @return a hash code for the aggregate pair. */ public int hashCode() ...

Get Programmer's Guide to Java™ Certification, A: A Comprehensive Primer, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.