Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

1
  • 2
    You are trying to bodge the hashing function to implement a table that is ordered by surname (or at least the first character of the surname) - this is not what hashing is for. A much simpler solution would be to wrap the surname, initials and phone number into a class that implements Comparable and use a data-structure that is automatically sorted such as TreeSet or programatically sort the data using Collections::sort. No need then to come up with a custom solution that violates the hash code contract. Commented Apr 24, 2019 at 15:19