Consider this class:
public final class MyDate { private int year, month, day; public MyDate(int year, int month, int day) { this.year = year; this.month = month; this.day = day; }
This is an ideal hashing function, because in memory we have:

So, in red, 5 bits save the day (from 1 to 31), in yellow 4 bits save the month (from 1 to 12), and the rest save the year (from 1 to 16777215).
What is the use of a perfect hashFunction ? AFAIK, it can guarantee the add / remove / contained in O(1) in the HashSet , but can I get other benefits from having one?
I saw that many hash functions use prime numbers, what is the best way to build one (I think creating an ideal uncommunication hash function is rare)?
<h> " EDIT:
About prime numbers β answered here
user2336315
source share