You are right about them ending up in the same bucket.
In the absence of an overridden equals
method, the JVM will just compare the object references for equality.
In your case you are passing the same object to map.get()
as you put in the map, so the references will be equal and so it matches the object.
Try creating:
Employee emp3CantFindMe = new Employee(33, "Arunan")
You'll find trying to retrieve that from the map will result in null even though it seems to be the "same" as emp3
.