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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.