public class Name implements Comparable{ private String firstName; private String lastName; public Name (String first, String last){ firstName = first; lastName = last; } public String toString(){ return firstName + " " + lastName; } public int compareTo (Name other){ if (lastName.compareTo(other.lastName) < 0) return -1; else if (lastName.compareTo(other.lastName) > 0) return 1; else // equal last names return firstName.compareTo(other.firstName); } }