If you want to make a mutable object as key in hashmap, then you have to make sure that state change for key object does not change the hash code of object. This can be done by overriding the hashCode() method . But, you must make sure you are honoring the contract with equals() also.
Read moreCan we use employee class as key in HashMap?
Answer to your question is yes, objects of custom classes can be used as a key in a HashMap.
Read moreHow does HashMap store data?
HashMap uses multiple buckets and each bucket points to a Singly Linked List where the entries (nodes) are stored . Once the bucket is identified by the hash function using hashcode, then hashCode is used to check if there is already a key with the same hashCode or not in the bucket(singly linked list).
Read moreHow does a HashMap store items in memory?
A HashMap stores data into multiple singly linked lists of entries (also called buckets or bins) . … All the keys with the same hash value are put in the same linked list (bucket). Keys with different hash values can end-up in the same bucket.
Read more