Example 5 (2)
Class declaration (continued) – implementation of the required methods:
public int compareTo (Date that) { // Return –1 if this date is earlier than that, // or 0 if this date is equal to that, // or +1 if this date is later than that. return (this.y < that.y ? -1 : this.y > that.y ? +1 : this.m < that.m ? -1 : this.m > that.m ? +1 : this.d < that.d ? -1 : this.d > that.d ? +1 : 0); }